I have created a form that sends its key/values via POST to a php script called admin.php. The gist of the script is this:
1. check to see if fname has been sent - if (isset($_POST['fname'])
2. if fname has been sent, then add the information to the faculty table (MYSQL database being used) and display the contents of the faculty table. If fname has not been sent, then display the contents of the faculty table.
The basic structure is:
******************************
if (fname present) {
add contents to db
if (@mysql_query($sql)) {
echo (databased updated)
}else {
echo(error)
}
}
Display contents of faculty table
*****************************
The problem I'm having is that after the DB is updated and displayed, if I then hit the refresh button, the member is added again to the DB because I'm essentially resending $_POST again and going through the script.
How can I prevent this from occuring? Should I have put the 'add to database' script in another php file?
Thanks. Also, I'm very new with php and MYSQL (but I'm moderately good with cgi).
Clearing the $_POST variable
Moderator: General Moderators