adamFTW
06-12-2007, 12:30 AM
I have the following code, but the info submitted doesn't submit to the database.
Any help?
<?php
// The database
include 'config.php';
// The variables
$name = ($_POST["name"]);
$grade = ($_POST["grade"]);
$comment = ($_POST["comment"]);
$ip = $_SERVER[REMOTE_ADDR];
//Those horrible IF's - Form data
if ($_GET["action"] == "submit")
{
if ($name == "")
{
echo "Whoops! You didn't enter your name.";
exit;
}
if ($comment== "")
{
echo "Whoops! You didn't enter a comment.";
exit;
}
$name = addslashes(htmlspecialchars($name));
$grade = addslashes(htmlspecialchars($grade));
$comment = addslashes(htmlspecialchars($comment));
$addpetition = mysql_query("INSERT INTO `petition` (`name`, `grade`, `comment`, `ip`) VALUES ('$name','$grade','$comment', '$ip')");
// The form details are fine, display text & details
echo "XX: <br />
Name: $name<br />
Grade: $grade<br />
Your comment: $comment<br />
<br />
To view all the signatures, click <a href=\"petition.php?view=entries\">here.</a> To go back to the home page, click <a href=\"index.php\">here.</a>";
exit;
}
else
// Display the form
{
echo "
<div align\"center\">XX</div><br />
<br />
<form action=\"?action=submit\" method=\"post\">
<div id=\"title\">Name:</div>
<input type=\"text\" name=\"name\"><br /><br />
<div id=\"title\">XX:</div>
<select name=\"XX\">
<option id=\"5\">XX</option>
<option id=\"5\">XX</option>
<option id=\"6\">XX</option>
<option id=\"7\">XX</option>
<option id=\"8\">XX</option>
</select><br /><br />
<div id=\"title\">Comment:</div>
<style=\"width=\"169\"; height=\"116\"><textarea rows=\"7\" input type=\"text\" name=\"comment\" cols=\"28\"></textarea><br />
<input type=\"submit\" name=\"submit\" value=\"Sign the petition!\">
</form>";
exit;
}
?>
Any help?
<?php
// The database
include 'config.php';
// The variables
$name = ($_POST["name"]);
$grade = ($_POST["grade"]);
$comment = ($_POST["comment"]);
$ip = $_SERVER[REMOTE_ADDR];
//Those horrible IF's - Form data
if ($_GET["action"] == "submit")
{
if ($name == "")
{
echo "Whoops! You didn't enter your name.";
exit;
}
if ($comment== "")
{
echo "Whoops! You didn't enter a comment.";
exit;
}
$name = addslashes(htmlspecialchars($name));
$grade = addslashes(htmlspecialchars($grade));
$comment = addslashes(htmlspecialchars($comment));
$addpetition = mysql_query("INSERT INTO `petition` (`name`, `grade`, `comment`, `ip`) VALUES ('$name','$grade','$comment', '$ip')");
// The form details are fine, display text & details
echo "XX: <br />
Name: $name<br />
Grade: $grade<br />
Your comment: $comment<br />
<br />
To view all the signatures, click <a href=\"petition.php?view=entries\">here.</a> To go back to the home page, click <a href=\"index.php\">here.</a>";
exit;
}
else
// Display the form
{
echo "
<div align\"center\">XX</div><br />
<br />
<form action=\"?action=submit\" method=\"post\">
<div id=\"title\">Name:</div>
<input type=\"text\" name=\"name\"><br /><br />
<div id=\"title\">XX:</div>
<select name=\"XX\">
<option id=\"5\">XX</option>
<option id=\"5\">XX</option>
<option id=\"6\">XX</option>
<option id=\"7\">XX</option>
<option id=\"8\">XX</option>
</select><br /><br />
<div id=\"title\">Comment:</div>
<style=\"width=\"169\"; height=\"116\"><textarea rows=\"7\" input type=\"text\" name=\"comment\" cols=\"28\"></textarea><br />
<input type=\"submit\" name=\"submit\" value=\"Sign the petition!\">
</form>";
exit;
}
?>