Forum Moderators: coopster

Message Too Old, No Replies

Retaining POST variable with second form

Need to "freeze/store" a variable when POST array refreshed

         

donwayne

12:41 pm on Nov 8, 2003 (gmt 0)



Hi - have tried most things and searched for solution,
probably overlooked some easy fix : )

Using an HTML FORM with hidden POST variable $Orig_Name
passing to the PHP script.

Single PHP SCRIPT:

Store variable with:- $New_Name = strtoupper($Orig_Name);
Use $New_Name as a trigger for various ops which are
then stored in further variables.

Use if / elseif for new form asking / checking for
name/email, using a print PHP / HTML Form :-
<FORM ACTION="'.$PHP_SELF.'" METHOD="POST">

To narrow down the issue I have temporarily put
a line of test variables on each HTML page :-
'."$variable1_2_test".'
'."$variable2_2_test".'
'."$variable3_2_test".' etc

ISSUE in PHP Script?:

All test variables appear on the PHP/HTML Form OK.
When clicking the Submit button on the PHP/HTML Form,
the variables selected with $Old/$New_Name disappear.

The POST variables name/email from the PHP/HTML
Form work fine, including my separately entered
default email address, entered as a variable at
the top of the script - appears through the script.

If I "hard code" $New_Name, the script works a treat.
Although I "store" the Original var to New var, once
Submit is hit in the PHP Form, $Orig_Name blanks and
$New_Name looses? its corresponding variable.

Is there a way to store $Orig_Name POSTed from the
original HTML form, and keep it in the PHP script,
no matter what - preferably without
JavaScript, files, cookies & database...

- as simple as possible : ) Many thanks, DonWayne

[edited by: donwayne at 1:30 pm (utc) on Nov. 8, 2003]

Robber

12:58 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



Hi and welcome to WebmasterWorld

I think what you need to do is include your variables in hidden form fields. That way they will get submitted with the rest of the form and you can still work with them, eg:

print '<input type="hidden" name="xyz" value="'.$your_var_here.'">';