QA.TechInterviews.com - your tech questions answered
Passing Varibles To Text Boxes In Different Browsers?
Scenario:

-Open a new webpage in a new browser in your PHP code.
-The new webpage has a username and password field

How do you pass the username and password you have stored in $variables in your PHP code to the username and password textbox on the new webpage?

Thanks
I recommend not ever auto-populating the password. This will make hacking the user's computer very easy.

To do what you are asking you can do it one of two ways -

1) store the variables server side in a database, etc. and then do option two or:

2) pass the variables directly using either cookies or get values -

the redirect is handled simply by:
header("Location: newUrl.php");

to add get values just add ?variable=value... after .php in the above code.

to set a cookie just run setcookie( 'var', 'val');

you would then, on the next page, just need to parse those variables out from where you saved them and set the value attribute of your text boxes like so:

<input type="text" value="<?php echo $var;?>" name="field" />
I recommend not ever auto-populating the password. This will make hacking the user's computer very easy.

To do what you are asking you can do it one of two ways -

1) store the variables server side in a database, etc. and then do option two or:

2) pass the variables directly using either cookies or get values -

the redirect is handled simply by:
header("Location: newUrl.php");

to add get values just add ?variable=value... after .php in the above code.

to set a cookie just run setcookie( 'var', 'val');

you would then, on the next page, just need to parse those variables out from where you saved them and set the value attribute of your text boxes like so:

<input type="text" value="<?php echo $var;?>" name="field" />

Back to QA. TechInterviews.com. Powered by Yahoo! Answers and TechInterviews.com community.