Hi guys,
I have a problem which has been sticking with me for 2 weeks now, I haven't found any solution so I decided i will start my own thread.
The problem:
I want to implement my calendar.php into my book.php . However everytime i try i get a blank screen on my localhost:8080/start/booking/book.php or it just wont insert the data into the database.
The files:
book.php
Code:
<?php
echo "<h1>book</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$service = strip_tags($_POST['service']);
$address = strip_tags($_POST['address']);
$veichle = strip_tags($_POST['veichle']);
$date = date ("Y-m-d");
if ($submit)
{
//check for existance
if ($fullname&&$service&&$address&&$veichle)
{
//register the user!
//encrypt password
// $password = md5($password);
// $repeatpassword = md5($repeatpassword);
//open our database
$connect = mysql_connect ("localhost", "root", "");
mysql_select_db("autoservice"); //select database
$queryreg = mysql_query("
INSERT INTO booking VALUES ('','$fullname','$service','$address','$veichle','$date')
");
die ("You have been registered! <a href='index.php'> Return to login page</a>");
}
}
else {
echo "Please fill in <b>all</b> fields!";
}
?>
<html>
<p>
<form action='book.php' method='POST'>
<table>
<tr>
<td>
Your full name:
</td>
<td>
<input type='text' name='fullname'>
</td>
</tr>
<tr>
<td>
Choose a service:
</td>
<td>
<input type='text' name='service'>
</td>
</tr>
<tr>
<td>
Address:
</td>
<td>
<input type='text' name='address'>
</td>
</tr>
<tr>
<td>
Veichle:
</td>
<td>
<input type='text' name='veichle'>
</td>
</tr>
</table>
<p>
<input type='submit' name='submit' value='Register'>
</form>
</html>
Calendar.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bookings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="calendarDateInput.js">
/***********************************************
* Jason's Date Input Calendar- By Jason Moon http://calendar.moonscript.com/dateinput.cfm
* Script featured on and available at http://www.dynamicdrive.com
* Keep this notice intact for use.
***********************************************/
</script>
</head>
<body>
<?php
$DBConnect = @mysql_connect("localhost", "root");
if (!$DBConnect)
{die("<p>The database server is not available</p>");
}
$dbselect = @mysql_select_db("autoservice");
if (!$dbselect){
die("<p>The database is not available</p>");
}
$inp = $_POST['date']; // Get the textbox that holds the date
$table_name='booking'; // Set the name of your table
$col_name = 'fromdate'; // Set the column that will hold the dates
if(isset($_POST['submit']))
{
$sQuery = "INSERT INTO $table_name($col_name) VALUES ('($inp)')"; // Insert query
//This function encodes will change any type of date and format it to (YYYY-mm-dd) and will store the date into mysql table
function encodeDate ($inp) {
$tab = explode ("-", $inp);
$r = $tab[2]."-".$tab[1]."-".$tab[0];
return $r;
}
mysql_query($sQuery) or die(mysql_error()); // Do the query
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<script>DateInput('date', true, 'YYYY-MM-DD')</script>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
More info:
The files work fine when testing them each seperately.
I also appreciate any help
please dont spam this thread i.e "Do it yourself" as I said i have been looking for 2 weeks.
Thank you
Bookmarks