Insert into MySQL DATE
Posted: Sun Aug 16, 2009 3:39 pm
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
2 questions here.
First the html
and the processing page.
This was more or less generated by formgen or some auto script at fatcow. It's over my head but I was able to alter it to meet my needs except for inserting a date into the table. I have been playing around with using Manual date but with no success.
Any advice would be great.
Second question same topic:
What would be idea is to use the same interface that you see on expedia.com or the other travel sites that give you a little calendar to select the date. Any ideas?
Many thanks,
Joe
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
2 questions here.
First the html
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/addcar.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p><img src="Images/A-1 Banner.jpg" /></p>
<br />
<form action="addcaraction.php" method="post">
<fieldset>
<legend>Add Car</legend>
<p><label for="year">Year:</label>
<input type="text" name="year" />
</p>
<p><label for="make">Make:</label>
<input type="text" name="make" />
</p>
<p><label for="model">Model:</label>
<input type="text" name="model" />
</p>
<p><label for="firstname">First name:</label>
<input type="text" name="firstname" />
</p>
<p><label for="lastname">Last name:</label>
<input type="text" name="lastname" />
</p>
<p><label for="phone">Phone:</label>
<input type="text" name="phone" />
</p>
<p><label for="address">Address:</label>
<input type="text" name="address" />
</p>
<p><label for="license">License:</label>
<input type="text" name="license" />
</p>
<p><label for="dateofloss">Date of Loss:</label>
<input type="text" name="dateofloss" />
</p>
<p class="submit"><input type="submit" value="Add Car" />
</p>
</fieldset>
</form>
</body>
</html>
Code: Select all
<?php
function pt_register()
{
$num_args = func_num_args();
$vars = array();
if ($num_args >= 2) {
$method = strtoupper(func_get_arg(0));
if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
}
$varname = "HTTP_{$method}_VARS";
global ${$varname};
for ($i = 1; $i < $num_args; $i++) {
$parameter = func_get_arg($i);
if (isset(${$varname}[$parameter])) {
global $$parameter;
$$parameter = ${$varname}[$parameter];
}
}
} else {
die('You must specify at least two arguments');
}
}
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','year');
pt_register('POST','make');
pt_register('POST','model');
pt_register('POST','firstname');
pt_register('POST','lastname');
pt_register('POST','phone');
pt_register('POST','address');
pt_register('POST','license');
pt_register('POST','dateofloss');
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Year: ".$year."
Make: ".$make."
Model: ".$model."
firstname: ".$firstname."
lastname: ".$lastname."
phone: ".$phone."
address: ".$address."
license: ".$license."
date of loss: ".$dateofloss."
";
$link = mysql_connect("data excluded");
mysql_select_db("cars1",$link);
$query="insert into cars (year,make,model,firstname,lastname,phone,address,license,dateofloss) values ('".$year."','".$make."','".$model."','".$firstname."','".$lastname."','".$phone."','".$address."','".$license."','".$dateofloss."')";
mysql_query($query);
header("Refresh: 0;url=http://towhereever.com");
?><?php
}
?>
Any advice would be great.
Second question same topic:
What would be idea is to use the same interface that you see on expedia.com or the other travel sites that give you a little calendar to select the date. Any ideas?
Many thanks,
Joe
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: