Jump to content

Recommended Posts

I have a form that users enter info into and then it's put into a mysql database. How do I clear the variables so that the user can not hit refresh on their browser and add another record. I've tried unset($var) or unset($_POST), but I must be missing something on what unset actually does as all the variables are still there when refresh is used.

 

I am using the same page for everything. I know I could use a seperate page, but it is all done this way now and I don't want to have to change everything.

 

Thanks

You could use

 

<?php 

// your form action here 

header('Location:your_page.php');
?>

 

to redirect the page after the form processing - this will then lose the $_POST variables.

the header will only run as long as you are not echoing anything to the browser.

You could use

 

<?php 

// your form action here 

header('Location:your_page.php');
?>

 

to redirect the page after the form processing - this will then lose the $_POST variables.

the header will only run as long as you are not echoing anything to the browser.

 

Then as I figured, you get the dreaded:

 

Warning: Cannot modify header information - headers already sent by (output started at ..............\rdr\rdr_registration.php:160) in ............\rdr\rdr_registration.php on line 272

 

So the question is then, how do I do this?

 

Basically I have a form that gets filled out.

 

After it is filled out and the user submits it I want to display a message that says, Thanks Bob, you are now registered and your ID is AAAAAABBB.

 

I have it working fine using one page, but then I get my original problem of the user hitting refresh and adding the record again.

 

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.