Hi,
I have been working on php for a little while and am having a little trouble. I have a working form and the fields get inserted into my mysql table correctly but the receipt page says that I did not enter anything into the firstname field or email field the two that I require people to enter information. Here is the code. Also if you go to the Website you can see what I mean. Thanks for your help.
<?php
include 'error.php';
include 'db.php';
$errorString = "";
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname] = trim(clean($value));
if(empty($formVars["firstname"]))
$errorString .="The first name field cannot be blank.";
if(empty($formVars["email"]))
$errorString .="You must supply an email address.";
if(!empty($errorString))
{
?>
<html>
<head>
<title>Guestbook Details Error</title>
</head>
<body bgcolor = "#FFFFFF">
<h1>Guestbook Errors</h1>
<?=$errorString?>
<br>
<a href="form.html">Return to the sign on for guestbook</a>
</body>
</html>
<?php
}
if(!($connection = @mysql_pconnect($hostname,$username,$password)))
die("Could not connect to database");
if(!mysql_select_db($databaseName, $connection))
showerror();
$query = "INSERT INTO guestbook (visitor_id, firstname, email, comments) values
('NULL','$firstname','$email','$comments')";
if(!(@($query,$connection)))
showerror();
$firstname = mysql_insert_id();
header("Location: thankyou.php?firstname=$firstname");
?>