ptmuldoon
03-12-2005, 03:32 PM
I hope this belongs here, and not in the mysql forum. If so, I apologize and could a mod please move it accordingly.
I mentioned earlier that I'm listening/watching and following along some php and mysql VTC's to try and learn. I've been making some basic newbie progress and am beginning to grasp some basic concepts. But, as expected of a newbie, I've stumbled, and dont' see whats wrong here.
In a nutshell, I've got two files, a html form, and a php script to write the info to a database. But I keep being told that I haven't enter all the fields even thought I have, and I can't seem to find the error.
The html form is simple and looks like this:
<html>
<head>
<title>Feedback form</title>
<body>
<h2>Feedback</h2>
<br>
<form action="send_feedback.php" method="post">
Your name is:
<input type=text name="user" maxlength=40 size=40>
<br>
Your email address is:
<input type=text name="email" maxlength=40 size=40>
<br><br>
Can we keep you updated with news about our site?
<input name="spam" type=radio value="1" checked>Yes
<input name="spam" type=radio value="1">No
<br><br>
Comments:
<br>
<textarea cols=40 rows=10 name="comments"></textarea>
<br>
<input type=submit value="submit">
</form>
</body>
</html>
And the php script looks like this:
<html?
<head>
<title>Thanks for your feedback</title>
</head>
<body>
<?
if(!$user || !$email || !$comments) {
?>
<h2>Please complete all of the fields</h2>
<br>
<a href="feedback.html">Click here to go back to the feedback page</a>
<?
exit;
}
$user = addslashes($user);
$email = addslashes($email);
$comments = addslashes($comments);
// Connect to the database
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("mots2", $db);
$addfeedback = "INSERT INTO feedback (user, email, spam, comments)
VALUES ('".$user."', '".$email."', '".$spam."', '".$comments."')";
$result = mysql_query($addfeedback);
?>
<h2>Thank you for your feedback</h2>
<br>
We have added your comments to the our database
</body>
</html>
I mentioned earlier that I'm listening/watching and following along some php and mysql VTC's to try and learn. I've been making some basic newbie progress and am beginning to grasp some basic concepts. But, as expected of a newbie, I've stumbled, and dont' see whats wrong here.
In a nutshell, I've got two files, a html form, and a php script to write the info to a database. But I keep being told that I haven't enter all the fields even thought I have, and I can't seem to find the error.
The html form is simple and looks like this:
<html>
<head>
<title>Feedback form</title>
<body>
<h2>Feedback</h2>
<br>
<form action="send_feedback.php" method="post">
Your name is:
<input type=text name="user" maxlength=40 size=40>
<br>
Your email address is:
<input type=text name="email" maxlength=40 size=40>
<br><br>
Can we keep you updated with news about our site?
<input name="spam" type=radio value="1" checked>Yes
<input name="spam" type=radio value="1">No
<br><br>
Comments:
<br>
<textarea cols=40 rows=10 name="comments"></textarea>
<br>
<input type=submit value="submit">
</form>
</body>
</html>
And the php script looks like this:
<html?
<head>
<title>Thanks for your feedback</title>
</head>
<body>
<?
if(!$user || !$email || !$comments) {
?>
<h2>Please complete all of the fields</h2>
<br>
<a href="feedback.html">Click here to go back to the feedback page</a>
<?
exit;
}
$user = addslashes($user);
$email = addslashes($email);
$comments = addslashes($comments);
// Connect to the database
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("mots2", $db);
$addfeedback = "INSERT INTO feedback (user, email, spam, comments)
VALUES ('".$user."', '".$email."', '".$spam."', '".$comments."')";
$result = mysql_query($addfeedback);
?>
<h2>Thank you for your feedback</h2>
<br>
We have added your comments to the our database
</body>
</html>