page forwarding after submit?
Posted: Wed Jun 05, 2002 10:39 am
1st question
I am trying to have a form that when the user fills in the fields and hits submit it writes to the database and forwards the user to a "thankyou.html" page. I can only get it to "print/echo" a message right now. Here is the code:
<?php
if ($submit) {
// process form
$db = mysql_connect("server", "user", "password");
mysql_select_db("database",$db);
$sql = "INSERT INTO table (first_name,last_name,email) VALUES ('$first_name','$last_name','$email')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
//the fields and html would be right here
<input type="submit" name="submit" value="Enter Information">
</form>
<?php
} // end if
?>
2nd question
How would I make this script so that it would only allow a user to vote once? Using IP and/or cookies...
thanks in advance.
J
I am trying to have a form that when the user fills in the fields and hits submit it writes to the database and forwards the user to a "thankyou.html" page. I can only get it to "print/echo" a message right now. Here is the code:
<?php
if ($submit) {
// process form
$db = mysql_connect("server", "user", "password");
mysql_select_db("database",$db);
$sql = "INSERT INTO table (first_name,last_name,email) VALUES ('$first_name','$last_name','$email')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
//the fields and html would be right here
<input type="submit" name="submit" value="Enter Information">
</form>
<?php
} // end if
?>
2nd question
How would I make this script so that it would only allow a user to vote once? Using IP and/or cookies...
thanks in advance.
J