page forwarding after submit?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jmandango
Forum Newbie
Posts: 19
Joined: Wed Jun 05, 2002 10:39 am
Location: Michigan

page forwarding after submit?

Post by jmandango »

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
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

Post by cwcollins »

use a redirect:

replace

Code: Select all

echo "Thank you! Information entered.\n";
with

Code: Select all

header("Location: http://www.whatever.com/thankyou.html");
c.w.collins
--finally got one right.
Post Reply