This is a discussion on "PHP: Help!" within the PHP Forum section. This forum, and the thread "PHP: Help! are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP: Help!
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
PHP: Help!
Hello,
I've got a form with two input boxes both with variables say $a and $b, when i submit the form i think there cached in the browers navigation bar. So when i hit refresh on the submit page it keeps adding to the MySql database. Is there a way to prevent this using the Location command? |
|
|
|
|||
|
Have talked to you via chat, but here is the same answer.
I've never heard of the location command, but you could include a hiddne field with an ID in the form. Then it doesn't matter how many times the user submits, there will only be one entry in the database. |
|
|||
|
Yeah, or use POST in your form instead of GET so the variables aren't cached in the URL.
|
|
|||
|
Is the user logged on? Are you storing the user_ID with the answer Or as suggested, a hidden ID will work (created randomly per session?). Put a unique constraint on the table where the data is stored. If an 'insert' command encounters no problems, it returns error number 0. If it encounters a unique key constraint violation, it returns 1062.
You can do something like: $result = mysql_db_query("database_Name",$strSQL); if (mysql_errno() == 1062) { echo "[img]images/warn.gif[/img]"; echo " [b]You already submitted this information!B> "; } |
![]() |
| Tags |
| php, help |
| Thread Tools | |
|
|