Reputation: 1477
When you send a form through HTML, if you send a form to the original page, will the PHP variables defined previously keep their values?
Upvotes: 1
Views: 72
Reputation: 787
Unless you use those magic-defined variables (highly-unrecommended!!) that puts each form variable into a equally-named variable in php and you load that variable into the form, you will need to explicitly put all the variables into the form. You can do that as follows:
<input type="text" value="<?php print($_POST['name']); ?>" name="name" />
Replace $_POST
with $_GET
according to your form method and the name with the name of the field!
Upvotes: 0
Reputation: 27886
No, any variables you to keep will have to be passed in the query string or form data. If you want to repopulate the form fields with the same data, you'll have to do that yourself as well, which may be as simple as doing this for each field:
<input type="text" name="city" value="<?= $_REQUEST['city'] ?>">
Upvotes: 0
Reputation: 25564
No. Script will run as new, all variables will be initiated again. If you want to keep some values - use session to store it.
Upvotes: 0
Reputation: 770
No, every time you refresh the page the variables will change, unless you use session variables.
Upvotes: 3