My error or success message is not in the right place, so I want to know how to get my message in the right place.
I have been searching the internet. I cannot find the right solution.
Here a photo what I mean.
<!DOCTYPE html>
<?php include('import_excel.php') ?>
<?php include('functions.php') ?>
<html lang="en" class=""><head>
<meta name="ac:base" content="/C:/xampp/htdocs/Angular-421-N-WORK-APP">
<meta charset="utf-8">
<title>N-WORK-USER | opslag-Sorting</title>
<meta name="description" content="app, web app, responsive, responsive layout, admin, admin panel, admin dashboard, flat, flat ui, ui kit, AngularJS, ui route, charts, widgets, components">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../libs/assets/animate.css/animate.css" type="text/css">
<link rel="stylesheet" href="../libs/assets/font-awesome/css/font-awesome.min.css" type="text/css">
<link rel="stylesheet" href="../libs/assets/simple-line-icons/css/simple-line-icons.css" type="text/css">
<link rel="stylesheet" href="../libs/jquery/bootstrap/dist/css/bootstrap.css" type="text/css">
<link rel="stylesheet" href="css/app.min.css" type="text/css">
<link rel="stylesheet" type="text/css" href="css/component.css">
<script>
(function(e,t,n){
var r=e.querySelectorAll("html")[0];r.className=r.className.replace(/(^|\s)no-js(\s|$)/,"$1js$2");
}
(document,window,0)
);
</script>
</head>
<body>
<!-- content -->
<div id="content" class="app-content" role="main">
<div class="app-content-body ">
<div ng-controller="FullcalendarCtrl">
<!-- main header -->
<div class="wrapper-md bg-yello b-b">
<h1 class="m-n font-thin h3">Lijst werkkracht TL GL Database</h1>
</div>
<!-- / main header -->
<div class="wrapper-md" ng-controller="FormDemoCtrl">
<div class="panel panel-defaultgrd">
<div class="panel-headinggrd font-bold text-blue">
Uitslag
</div>
<div class="panel-body">
<div class="hbox hbox-auto-xs hbox-auto-sm">
<div class="container">
<div class="row">
<div class="col-md-12 control-label">
<button class="btn btn-info">Database invoegen</button>
<a class="btn btnx btn-orange" id="download-btn" target="_new"><i class="fa fa-download"></i> Export to Excel</a>
<form method="post" action="import_excel.php" enctype="multipart/form-data">
<div class="form-groupp" style="">
<input type="file" name="file-7" id="file-7" class="inputfile inputfile-6" data-multiple-caption="{count} files selected" multiple=""><label for="file-7"><span></span> <strong><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"></path></svg> Import Excel..</strong></label>
</div>
<a class="btnl"><button class="btn btn-info" style="">Upload</button></a>
</form>
<div class="table-responsive">
<table id="mytable" class="table table-bordred table-striped">
<thead>
<tr>
<th>#</th>
<th>MBU</th>
<th>Zone</th>
<th>Omschrijving</th>
<th>TL</th>
<th>GL</th>
<th>Stand in lijn</th>
<th>Station</th>
<th>MBU nr</th>
<th>WO stap</th>
<th>LOG stap</th>
<th>Q stap</th>
<th>RA stand</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
$fetchdata=new DB_con();
$sql=$fetchdata->fetchdata();
$cnt=1;
while($row=mysqli_fetch_array($sql))
{
?>
<tr>
<td><?php echo htmlentities($cnt);?></td>
<td><?php echo htmlentities($row['MBU']);?></td>
<td><?php echo htmlentities($row['zone']);?></td>
<td><?php echo htmlentities($row['omschr']);?></td>
<td><?php echo htmlentities($row['tl']);?></td>
<td><?php echo htmlentities($row['gl']);?></td>
<td><?php echo htmlentities($row['stand_in_lijn']);?></td>
<td><?php echo htmlentities($row['station']);?></td>
<td><?php echo htmlentities($row['MBU_nr']);?></td>
<td><?php echo htmlentities($row['WO_stap']);?></td>
<td><?php echo htmlentities($row['LOG_stap']);?></td>
<td><?php echo htmlentities($row['Q_stap']);?></td>
<td><?php echo htmlentities($row['RA_stand']);?></td>
<td><button class="btn btn-info btn-xs"><span class="glyphicon glyphicon-pencil"></span></button></td>
<td><button class="btn btn-danger btn-xs" onclick="return confirm('Wil je bestand echt verwijderen?');"><span class="glyphicon glyphicon-trash"></span></button></td>
</tr>
<?php
// for serial number increment
$cnt++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- / main -->
</div>
</div>
<!-- /content -->
<!-- footer -->
<footer id="footer" class="app-footer" role="footer">
<div class="wrapper b-t bg-light">
<span class="pull-right">2.3.0 <i class="fa fa-long-arrow-up"></i></span>
© 2018 Copyright.
</div>
</footer>
<!-- / footer -->
<script src="js/app.min.js"></script>
</body>
</html>
my other code import_excel.php
<?php
/**
* RaeCreated by Homensdigiworld.
* Admin: Stefaan
* Date: 26-03-2019
*/
include_once "app_opslag_database_tl_gl.php";
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Common\Type;
require_once ('connect.php');
require_once ('Spout/Autoloader/autoload.php');
if(!empty($_FILES['file-7']['name']))
{
// Get File extension eg. 'xlsx' to check file is excel sheet
$pathinfo = pathinfo($_FILES['file-7']['name']);
// check file has extension xlsx, xls and also check
// file is not empty
if (($pathinfo['extension'] == 'xlsx' || $pathinfo['extension'] == 'xls')
&& $_FILES['file-7']['size'] > 0 )
{
$file = $_FILES['file-7']['tmp_name'];
// Read excel file by using ReadFactory object.
$reader = ReaderFactory::create(Type::XLSX);
// Open file
$reader->open($file);
$count = 0;
// Number of sheet in excel file
foreach ($reader->getSheetIterator() as $sheet)
{
// Number of Rows in Excel sheet
foreach ($sheet->getRowIterator() as $row)
{
// It reads data after header. In the my excel sheet,
// header is in the first row.
if ($count > 0) {
// Data of excel sheet
$MBU = $row[1];
$zone = $row[2];
$omschr = $row[3];
$tl = $row[4];
$gl = $row[5];
$stand_in_lijn = $row[6];
$station = $row[7];
$MBU_nr = $row[8];
$WO_stap = $row[9];
$LOG_stap = $row[10];
$Q_stap = $row[11];
$RA_stand = $row[12];
//Here, You can insert data into database.
$qry = "INSERT INTO `users`(`MBU`, `zone`, `omschr`, `tl`, `gl`, `stand_in_lijn`, `station`, `MBU_nr`, `WO_stap`, `LOG_stap`, `Q_stap`, `RA_stand`) VALUES ('$MBU','$zone','$omschr','$tl','$gl','$stand_in_lijn','$station','$MBU_nr','$WO_stap','$LOG_stap','$Q_stap','$RA_stand')";
$res = mysqli_query($con,$qry);
}
$count++;
}
}
if($res)
{
echo "Your file Uploaded Successfull";
}
else
{
echo "Your file Uploaded Failed";
}
// Close excel file
$reader->close();
}
else
{
echo "Please Choose only Excel file";
}
}
else
{
echo "File is Empty"."<br>";
echo "Please Choose Excel file";
}
?>
I have that message : Undefined variable: _SESSION in C:\xampp\htdocs\import-excel_08\index.php on line 29
You are including the upload file at the top of your main page file.
<?php include('import_excel.php') ?>
It doesn't need to be included as it does nothing on that page, your form submits to that file.
Remove it from the top of that page and the message should go away.
Related
how can I automatically save this pizza image, and save it to my local folder? I can easily save the other information, but I'm encountering automatically saving the image itself in a local folder?
I'm fetching the other data from different table, but the I can't save the image itself. I'm have no intention of using foreign key for no.
backend.php
if (isset($_POST['addcart'])) {
$con = connection();
$fetch = singleInfo();
$name = $fetch['name'];
$price = $fetch['price'];
$image = $fetch['image'];
$new_image = '../images/' . $image;
$stmt = $con->prepare("INSERT INTO `cart`(`name`, `price`,`image`) VALUES ('$name','$price','$new_image')");
$stmt->execute();
}
index.php
<?php
session_start();
require('../backend/clientbackend.php');
$fetch = singleInfo();
$current_price = $fetch['price'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style/style.css">
<title>E-Commerce</title>
</head>
<body>
<nav>
<div class="left">
<h4 class="navbar-header"> Branding </h4>
<ul>
<li>Home</li>
<li>Shop</li>
<li>About</li>
</ul>
</div>
<div class="right">
<button class="loginButton">Login</button>
</div>
</nav>
<article>
<form method="post" class="product-description">
<div class="left">
<div class="left-title" name="name"> <?php echo $fetch['name']; ?> </div>
<div class="left-info">
<p class="left-description"> <?php echo $fetch['desc']; ?> </p>
<span class="price" name="price"> $ <strong> <?php echo $fetch['price']; ?></strong> </span>
</div>
<div class="left-increment">
<div class="addition">+</div>
<input type="number" class="current_value" value="1" min="1">
<div class="subtraction">-</div>
<button class="gotoCart" name="addcart" type="submit"> Add To Cart </button>
Go to cart
</div>
</div>
<div class="right">
<div class="right-image">
<img name="image" src="<?php echo '../uploads/' . $fetch['image']; ?>" alt="">
</div>
</div>
</form>
</article>
<footer>
<div class="footer-container">
<div class="box1">
<h3>Ecommerce Branding</h3>
<span>School Activity</span>
</div>
<div class="box2">
<h3>Colegio De San Lorenzo
</h3>
<span>Congressional Ave, Project 8, Quezon City, Metro Manila</span>
</div>
<div class="box3">
<h3>Emman Cruz</h3>
<span> zurcemozz#gmail.com</span>
</div>
</div>
</footer>
<script>
const addBtn = document.querySelector('.addition');
const subBtn = document.querySelector('.subtraction');
let currentValue = document.querySelector('.current_value');
let stock = 1;
addBtn.addEventListener("click", function() {
stock = stock + 1
currentValue.value = stock;
console.log(currentValue.value);
})
subBtn.addEventListener("click", function() {
if (stock <= 0) {
stock = 0;
} else {
stock = stock - 1
currentValue.value = stock;
console.log(currentValue.value);
}
})
</script>
</body>
</html>
you can copy the image file from '../uploads/' to '../images/' and then you save it .
you can do this with copy function
copy documentations
copy() example :
<?php
$image = '../uploads/'.$fetch['image'];
$new_image= '../images/'.$fetch['image'];
if (!copy($image , $new_image)) {
echo "failed to copy $image ...\n";
}
?>
I'm making a website for my school and my website is like a laptop store and the main thing in my webpage is a product filter. I have made the product filter, it works great, but the problem is that I added shortcuts that send you to a single product page by clicking one of the products in the product filter. You can click on a product when you just came in the website and haven't messed with the product filter and it sends you to the single product page, but once you search for something using the filter the filtrated product cant be clicked on and you have to refresh the page to select your product. This is happening, because when you come in the website, you see index.php, but once you use the product filter, you are seeing action.php.
here is a part of my code from index.php:
<?php
$sql="SELECT * FROM Laptop";
$result=$conn->query($sql);
if ($result-> num_rows > 0) {
while($row=$result->fetch_assoc()){
$Laptop_ID = $row['Laptop_ID'];
?>
<?php echo "<a href='single_laptop.php?Laptop=" . $Laptop_ID ."'>" ?>
<div class="col-md-3 mb-2" style="color: blue">
<div class="card-deck">
<div class="card boarder-secondary">
<div class="card-img-overlay">
<h6 class="text-light bg-success text-center rounded p-1">
<?= $row['Nosaukums']; ?></h6>
</div>
<br>
<img src="<?= $row['Bilde']; ?>" class="card-img-top">
<div class="card-body">
<p>
Procesors : <?= $row['Procesors']; ?><br>
Videokarte : <?= $row['Videokarte']; ?><br>
RAM : <?= $row['RAM']; ?><br>
</p>
</div>
</div>
</div>
</div>
<?php }
}else {
echo "nav rezultātu";
}?>
</div>
</div>
</div>
And here is my action.php:
<?php
require 'dataB.php';
if(isset($_POST['action'])){
$sql = "SELECT * FROM Laptop WHERE Modelis !=''";
if(isset($_POST['Modelis'])){
$Modelis = implode("','", $_POST['Modelis']);
$sql .="AND Modelis IN('".$Modelis."')";
}
if(isset($_POST['Tips'])){
$Tips = implode("','", $_POST['Tips']);
$sql .="AND Tips IN('".$Tips."')";
}
if(isset($_POST['RAM'])){
$RAM = implode("','", $_POST['RAM']);
$sql .="AND RAM IN('".$RAM."')";
}
if(isset($_POST['Procesors'])){
$Procesors = implode("','", $_POST['Procesors']);
$sql .="AND Procesors IN('".$Procesors."')";
}
if(isset($_POST['Videokarte'])){
$Videokarte = implode("','", $_POST['Videokarte']);
$sql .="AND Videokarte IN('".$Videokarte."')";
}
$result = $conn->query($sql);
$output='';
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
$output .='
<div class="col-md-3 mb-2" style="color: blue">
<div class="card-deck">
<div class="card boarder-secondary">
<div class="card-img-overlay">
<h6 class="text-light bg-success text-center rounded p-1">
'.$row['Nosaukums'].'</h6>
</div>
<br>
<img src="'.$row['Bilde'].'" class="card-img-top">
<div class="card-body">
<p>
Procesors : '.$row['Procesors'].'<br>
Videokarte : '.$row['Videokarte'].'<br>
RAM : '.$row['RAM'].'<br>
</p>
</div>
</div>
</div>
</div>';
}
} else {
$output = "<h3>No Products Found!<h3>";
}
echo $output;
}
?>
I need to figure out how to properly put the code from index.php, where it makes it possible to redirect me to single.laptop.php, to action.php, so I can redirect to single_laptop.php with no problems using the product filter.
$(document).keydown(function(e){
var keycode=e.keyCode;
if (keycode == 27)
{
$("#change").trigger('click');
}
});
$("#change").click(function() {
//do what you need
if($("#radio:checked").length==0)
{
alert("abc");
return false;
}
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#3.3.7/dist/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#3.3.7/dist/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
Press ESC
</body>
</html>
I did complete a website for online Entrance form for students as my demo project to learn. When I run from my local server it works fine but when I uploaded on webserver and tasted index.php and other files run fine except when user enter his/her symbol no to check if he/she already been registered or not..I have coded a logic
if (exists)>Show admit card
if(don't exist)>show alert box
It works fine in local server but in webserver when I enter value in search box and enter then it shows empty page with no any error.
I have one row in my database. So in case you wanna check here is the symbol no in column =15369-2017-02 . On Entering submit it should show admit card and you can enter any random value other then this .which should show alert box.
Here is my website
https://cmprc.edu.np/condensed/entrance_form_demo/studntreport/main/
This is the code of file which is not responding and showing blank
<html>
<head>
<title>
CDP || Admission Form
</title>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="../style.css" media="screen" rel="stylesheet" type="text/css" />
<body style="background-color: white;">
<?php
include('../connect.php');
$var_value = $_POST['search_value'];
echo $var_value;
$sql="SELECT * FROM entrance WHERE re_value='$var_value'";
$STH = $db->prepare($sql);
$STH->execute(array($var_value));
$User = $STH->fetch();
if (empty($User))
echo "<script>alert('Sorry, you Have not Registered yet');
window.location = 'index.php';</script>";
else
$result = $db->prepare("SELECT * FROM entrance
WHERE re_value = '$var_value' ORDER BY id ASC;");
$result->execute();
for($i=0; $row = $result->fetch(); ){
?>
<link href="../style.css" media="screen" rel="stylesheet" type="text/css" />
<center><h4><i class="icon-edit icon-large"></i> You've Already Registered</h4></center>
<hr>
<center>
<div class="panel panel-default">
<div class="container">
<div class="row">
<div class="col-md-4 seventy">
<img src="img/admit.png"/ >
</div>
<div class="col-md-8 thirty">
<img src="../image/profile/<?php echo $row['pic_value'];?>" class="roundimage2" alt=""/>
</div>
</div>
</div>
<hr>
<table style=" width: 500px;">
<tr>
<td >Roll no: </td>
<td> <?php echo $row['id']; ?></td>
</tr>
<tr>
<td >Name : </td>
<td > <?php echo $row['name_en_value']; ?></td>
<td > Subject: </td>
<td > <?php echo $row['ge_value']; ?> </td>
</tr>
</table>
<br><br>
<h5><i><strong>STUDENTS MUST BRING THIS ADMIT CARD ON THE DAY OF EXAMINATION</strong></i></h5>
<br>
</div>
</center>
<?php
}
?>
</body>
<?php include('footer.php');?>
</html>
Any help? I did almost finished it which I was working continously for 4-5 Days.
It seems that your php is not executed correctly. Maybe try to enable error reporting to get a hint of what's wrong.
Include the following at the beginning of your destination file (my.php)
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
It's the last piece of this that eludes me, I'm hoping someone can shed some light on what's missing.
The longer part of this code works just fine, it's the UPDATE portion (in the
dis_adjust.php file) that's causing the grief.
In place of the hard coded number 13, it needs to accept the variable 'catID'.
The variable 'catID' initially filters for the number 1, and is then UPDATED to 5 when the "Rewarded" button is clicked.
Not sure if I'm explaining it correctly, or clearly...perhaps it's the sleep deprivation.
dis_adjust.php
<?php
require 'dis_db.php';
$tag_h_id = $_GET['id'];
$sql = 'UPDATE `coh_items` SET `enabled`=5, `rewarded_at`= now() WHERE `category_id`=13 AND `tag_h_id`=:id';
$statement = $connection->prepare($sql);
if ($statement->execute([':id' => $tag_h_id])) {
header("Location: http://localhost/green/management/disbursements.php");
}
<?php
require 'dis_db.php';
$sql = 'SELECT
coh_items.id,
coh_items.tag_h_id,
coh_vendors.name,
coh_vendors.phone,
coh_vendors.tax_number,
coh_vendors.currency_code,
coh_items.purchase_price,
COUNT(tag_h_id) AS Reports,
(
purchase_price * COUNT(tag_h_id)
) AS Reward
FROM
coh_items
INNER JOIN coh_vendors ON coh_items.tag_h_id = coh_vendors.id
WHERE
coh_items.enabled = 1 AND category_id = ?
GROUP BY
tag_h_id;';
$statement = $connection->prepare($sql);
//$statement ->bindParam(':category_id', $catID, PDO::PARAM_INT);
$statement->execute([$_POST['catID']]);
$people = $statement->fetchAll(PDO::FETCH_OBJ);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Disbursement</title>
<link rel="stylesheet" href="http://localhost/green/vendor/almasaeed2010/adminlte/bootstrap/css/bootstrap.min.css">
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<!-- <script src="http://localhost/green/vendor/almasaeed2010/adminlte/bootstrap/js/bootstrap.js"></script> -->
<style type="text/css">
</style>
<script type="text/javascript">
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header clearfix">
<h3 class="center">Details by Category</h3>
<div>
<!--Filter Button -->
<div>
<div class="col-md-2">
<p class="margin"></p>
<div class="input-group">
<div class="input-group-btn">
<form action="http://localhost/green/management/disbursements.php" method="post">
<input type="text" name = "catID" placeholder="Category" class="form-control" >
<input type="submit" value= "Filter" class="btn btn-primary ">Filter</button></d>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
<div class="col-md-8">
<table class="table table-bordered">
<tr>
<th>ID</th>
<th>Name</th>
<th>Phone</th>
<th>Zip</th>
<th>Status</th>
<th>Number of Reports</th>
<th>Award</th>
<th>Action</th>
</tr>
<?php foreach($people as $person): ?>
<tr>
<td><?= $person->tag_h_id; ?></td>
<td><?= $person->name; ?></td>
<td><?= $person->phone; ?></td>
<td><?= $person->tax_number; ?></td>
<td><?= $person->currency_code; ?></td>
<td><?= $person->Reports; ?></td>
<td><?= $person->Reward; ?></td>
<td>
<a href="./disbursements/dis_adjust.php?id=<?= $person->tag_h_id ?>" name = 'adjust' class='btn btn-success'>Rewarded</a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
PDO prepared statements can accept an arbitrary number of parameters. To modify yours to use the variable $catId, change your query to:
$sql = 'UPDATE `coh_items` SET `enabled`=5, `rewarded_at`= now() WHERE `category_id`=:cat_id AND `tag_h_id`=:id';
and the execute call to:
$statement->execute([':id' => $tag_h_id, ':cat_id' => $catID])
So, my formular is redirecting to the wrong site!
Look at my example:
ATM I've got the internet address:
http://localhost/myworkspace/mywebsite/index.php
It's hosted on a localhost-xampp server. It's homepage is:
http://localhost/xampp/
Ok ... Now I tried several things to get into the file where the script is that is working with the data of the formular:
<form action="index.php">
-> I'm getting redirected to the Xampp Homepage
<form action="index.php?mod=home">
-> I'm getting redirected to the Xampp Homepage
<form action="myworkspace/mywebsite/index.php">
-> I'm getting redirected on "http://localhost/myworkspace/mywebsite/myworkspace/mywebsite/index.php"
(the arrows express what happens when clicking on "send")
Why is this happening? As seen in the examples, the browser is not moving outside the myworkspace/mywebsite-folders. But still, it loads the index.php which is located in localhost/xampp (it's localhost/index.php). If you see my original link of the website, there actually is an index.php file in "myworkspace/mywebsite".
Here's some code of me:
the addguestbook.php, which is included into the index.php (see below)
<?php
//******************************************************//
//********************Database stuff********************//
//******************************************************//
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="mywebsite"; // Database name
//********************Tables***************************//
$tbl_name="guestbook"; // Guestbook
echo $hostname.$path.$get;
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$comment = $_POST['comment'];
$datetime = date("l, jS M Y, g:i a"); //date time
// Connect to server and select database.
mysql_connect($host, $username, $password)or die("cannot connect server: ".mysql_error());
mysql_select_db($db_name)or die("cannot select DB: ".mysql_error());
$sql="INSERT INTO ".$tbl_name."(id, name, email, website, comment, datetime)VALUES('".$post_id."', '".$name."', '".$email."', '".$website."', '".$comment."', '".$datetime."')";
$result=mysql_query($sql);
mysql_close();
} else
?>
<form method="post" action="myworkspace/mywebsite/index.php">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="guestbookFormCell" colspan='2'><input
class="guestbookInputFieldText" name="name" type="text"
value="Name *" size="40" maxlength="30" /></td>
</tr>
<tr>
<td class="guestbookFormCell" colspan='2'><input
class="guestbookInputFieldText" name="email" type="text"
value="E-Mail (won't become displayed)" size="40" maxlength="40" />
</td>
</tr>
<tr>
<td class="guestbookFormCell" colspan='2'><input
class="guestbookInputFieldText" name="website" type="text"
value="Website" size="40" maxlength="50" /></td>
</tr>
<tr>
<td class="guestbookFormCell" colspan='2'><textarea
class="guestbookInputFieldText" name="comment" cols="37" rows="5">Comment *</textarea>
</td>
</tr>
<!--
<tr>
<td>CAPTCHA</td>
</tr>
-->
<tr>
<td><button class="guestbookFormCell guestbookButton" type="submit"
name="submit">
<span class='guestbookButtonText'>Send</span>
</button></td>
<td><button class="guestbookFormCell guestbookButton" style="float:right;"type="reset"
name="reset">
<span class='guestbookButtonText'>Reset</span>
</button></td>
</tr>
</table>
</form>
and the index.php (it's pretty big. most of it is just a design-structure, so ignore the html stuff. it's just divs and tables.
<html>
<head>
<title>JustBasti's website</title>
<script type="text/javascript" src="lightbox/js/prototype.js"></script>
<script type="text/javascript"
src="lightbox/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="lightbox/js/lightbox.js"></script>
<link rel="stylesheet" href="lightbox/css/lightbox.css" type="text/css"
media="screen" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
session_start();
// Path-parameters for link-building
$hostname = $_SERVER['HTTP_HOST'];
$path = $_SERVER['PHP_SELF'];
$_SESSION['basepath'] = dirname($_SERVER['PHP_SELF']);
?>
<div id='top'>
<div id='header'>
<div id='headerText' class='lightText text bigText'>
<div>
Hello, My name is <font class='blueText'>Sebastian Fast</font>
</div>
<div>
I just finished my <font class='blueText'>education in IT</font>
</div>
<div>
and am now <font class='blueText'>aiming to</font>
</div>
<div>
experience the <font class='blueText'>most wonderful places</font>
</div>
<div>
around <font class='blueText'>the world</font>
</div>
<div>
Read more about myself <font class='blueText'>here</font>
</div>
</div>
<div id='headerLineBox'>
<div class='lineTopDiv'>
<div id='headerTopLine' class='lineTopEnd'></div>
</div>
<div class='verticalLine'>
<div id='headerLine' class='line'></div>
</div>
<div class='lineBottomDiv'>
<div class='lineBottomEnd'></div>
</div>
</div>
<div id='headerNavigation' class='lightText text bigText'>
<div>
<a href='index.php?mod=home' class='lightLink'>Home</a>
</div>
<div>
<a href='index.php?mod=news' class='lightLink'>News</a>
</div>
<div>
<a href='index.php?mod=countries' class='lightLink'>Countries</a>
</div>
<div>
<a href='index.php?mod=gallery' class='lightLink'>Gallery</a>
</div>
</div>
</div>
</div>
<div id='middle'>
<div id='content'>
<table>
<!-- CONTENT -->
<?
// Paths
echo " <a href='index.php?mod=home'>Home</a>
<a href='index.php?mod=news'>News</a>
<a href='index.php?mod=allnews'>All News</a>
<a href='index.php?mod=countries'>Countries</a>
<a href='index.php?mod=gallery'>Gallery</a>
<a href='index.php?mod=guestbook'>Guestbook</a>
<a href='index.php?mod=admin'>Administrator</a>";
if (!isset($_SESSION['angemeldet']) || !$_SESSION['angemeldet']) {
include('login/login.php');
}
// Check which link got clicked & import data
if (!$_GET){
include('data/home.php');
} elseif (isset($_GET['mod']) && !isset($_GET['post']) && !isset($_GET['album']) && !isset($_GET['country'])){
Switch($_GET['mod']){
case 'home':
include('data/home.php');
exit;
case 'news':
include('data/latestPosts.php');
exit;
case 'allnews':
include('data/allPosts.php');
exit;
case 'countries':
include('data/viewCountries.php');
exit;
case 'gallery':
include('data/gallery.php');
exit;
case 'admin':
include('admin/admin.php');
exit;
}
} elseif (isset($_GET['mod']) && isset($_GET['post'])){
$get = "?mod=".$_GET['mod']."&post=".$_GET['post'];
$post_id = $_GET['post'];
include('data/viewPost.php');
include('data/guestbook.php');
} elseif (isset($_GET['mod']) && isset($_GET['album'])){
$get = "?mod=".$_GET['mod']."&album=".$_GET['album'];
$post_id = $_GET['album'];
include('data/viewAlbum.php');
include('data/guestbook.php');
} elseif (isset($_GET['mod']) && isset($_GET['country'])){
$country = $_GET['country'];
include('data/viewCountry.php');
}
?>
</table>
</div>
</div>
<div id='graphicDIV'>
<div id='graphic'></div>
</div>
<div id='bottom'>
<div id='guestbook'>
<table border='0' cellspacing='0' cellpadding='0'>
<tr>
<td id='guestbookHeadline1'><font class='lightText bigText text'>Allgemeines Gästebuch</font>
</td>
<td id='guestbookTopLine' class='lineTopEnd'></td>
<td id='guestbookHeadline2'><font class='lightText bigText text'>Schreibe selbst</font>
</td>
</tr>
<tr id='guestbook2'>
<?
$post_id = 000000000000;
$get = "?mod=home";
?>
<td id='guestbookComment'>
<? include('data/viewguestbook.php'); ?>
</td>
<td id='guestbookLine'></td>
<td id='guestbookFormular'>
<? include('data/addguestbook.php'); ?>
</td>
</tr>
</table>
</div>
<div id='footerLeftLine' class='lineLeftEnd'>
<!-- LineLeftEnd -->
</div>
<div id='footerLine' class='horizontalLine'>
<!-- Line -->
</div>
<div id='footerRightLine' class='lineRightEnd'>
<!-- LineRightEnd -->
</div>
<div id='footer'>
<div class='footerLink'>
<!-- AdministratorLink -->
</div>
<div class='footerLink'>
<!-- ImpressumLink -->
</div>
<div class='footerLink'>
<!-- NewsArchiveLink -->
</div>
</div>
</div>
</body>
</head>
</html>
Thanks for help!
<form action="myworkspace/mywebsite/index.php">
should be
<form action="/myworkspace/mywebsite/index.php">
What you currently have is a path relative to your current page. The path that I have given is relative to your document root, which is http://localhost.
See also:
Absolute and Relative Paths, from About.com
Path (computing), from Wikipedia