Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep script from running upon page refresh 1

Status
Not open for further replies.

tyhand

Programmer
Joined
Jul 3, 2002
Messages
186
Location
US
Hey all,

Just finished writing my first php script and it does work.
However, every time I do a web page refresh/reload (on the page that contains the script), it runs. In fact, every visit to the web page runs the script. This is not what I wanted.

What can I do to prevent this?

The script simply parses information on a form and then sends me an email. I only want the script to run when information is sent to it from my form, not every time the web page with the script gets loaded/reloaded. Should I place the script within a sub or function? Would this make a difference?

Any and all help is greatly appreciated. Thanks. Peace!

Thank
You
Have
A
Nice
Day
 

Form uses POST Method. My script parses form fields using
$_REQUEST[]

Thanks!
 
As an aside, I strongly recommend against using $_REQUEST. It has some of the same variable-poisoning security problems as running PHP with register_globals set to "on". I recommend that you use $_GET and $_POST and $_COOKIE separately instead.


You might try having your script check for a session variable's having a certain value. If the variable does not exist or if it does not hold the expected value, the script processes the form and sets the session variable. Otherwise, the script falls back to another action or perhaps does nothing.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top