Deron,
By doing a Post to itself, this form will cause an error everytime someone
clicks the Back button on the browser (after the first post, of course).
What I do is have two forms, first invoked with a get via hot link or
redirect.
Form_1.php checks to see if variable $s has been passed (in the URL, of
course), if not it initializes and displays the form. The Form action on
this displayed form indicates to "Post" to Form_2.php.
Form_2.php displays nothing, just processes variables on the form. This one
would insert the row, and to avoid thread problems (multiple simultaneous
inserts, from multiple users) has a unique "autoincrement" variable as the
primary key to the table (MySQL will make the insert "thread safe"). When
the insert is successful this routine redirects the browser back to form_1
like so;
Header("Location: Form_1.php?s=$insertid");
Exit;
When control is passed to Form_1.php again, this time the variable $s is set
and the row is retrieved from the table (instead of using initialization
values) and displayed in the form giving confirmation of the updates that
were done.
Because Form_2 redirects to Form_1, Form_1 is the only one on the browser
history list(each separate instance is tracked, of course), and it is always
entered via a Get, meaning that the browser does include the passed variable
values in the history list (it doesn't do this with a Post). And the Back
button works. In the Post error you are working toward, the browser
complains that it does not have a record of the "Post" variable values (the
Data Has Expired).
There may be other ways to deal with this, but this is one way that I have
found that works.
Good Luck,
Warren Vail
-----Original Message-----
From: Deron [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 21, 2001 11:38 PM
To: [EMAIL PROTECTED]
Subject: [PHP] "Talkback" or community type participation.....
Hi there!
I have this script I just made based on a tutorial I found online and was
wondering if there was a better way to do this or not. Everything works
great so far except for a couple little things. Once the $submit is clicked
and runs the INSERT data into the table... I am looking to be able to have
the page auto refresh and display the new entry as well as the form again.
Here's my current code: (I have this built into the main review page via an
include. The entire page can be viewed here:
http://www.metalages.com/2002/reviews/reviews-test.php?band=Evergrey&album=I
n%20Search%20of%20Truth
Feel free to post a dummy message, nothing is live yet, all in test mode :)
you'll notice once the entry is submitted also, if you try to refresh the
page it wants to readd the data again. any help or guidance appreciated, I
am a self professed "still learning this stuff"! kinda guy.
<?php
if ($submit) {
// Process Form
$DBconn = mysql_connect("localhost", "user", "pass");
mysql_select_db("databasename", $DBconn);
if (!$DBconn) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
$sql = "INSERT INTO talkback (band_id, album_id,
talkback_name,talkback_email,talkback_comments) VALUES
('$currentid[0]','$currentid[1]','$talkback_name','$talkback_email','$talkba
ck_comments')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else {
// display form
?>
<form method="post" action="<?php echo "$PHP_SELF" . "?band=$band" .
"&album=$album"?>">
<div align="center"><b>Name/Nickname:</b><br>
<input type="Text" name="talkback_name"><br>
<b>Email (optional):</b><br>
<input type="Text" name="talkback_email"><br>
<b>Comments:</b><br>
<textarea name="talkback_comments" cols="50" rows="5"></textarea>
<br>
<input type="Submit" name="submit" value="Speak Your Metal!">
</div>
</form>
<?php
} // end if
?>
Deron
www.metalages.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]