It is necessary to transfer data from one html form on one page to another html form on another page. Another page is opened by the submit button in the form on the first page, in it the form with the fields already filled in from the corresponding fields of the first page.
Closed due to the fact that the issue is too general for the participants HamSter , Denis , tutankhamun , Bald , rjhdby 17 Oct '16 at 7:53 .
Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
2 answers
To transfer data between forms, you can use the POST method.
Example of implementation:
Create the first form, for example, like this:
<form action="action.php" method="post"> <p>Ваше имя: <input type="text" name="name" /></p> <p>Ваш возраст: <input type="text" name="age" /></p> <p><input type="submit" /></p> </form> Where:
action.phpis another page / file where you will transfer values (you can set your own version)- All that is in between
<form> ... </form>- ask yourself what fields you need. - The last element is
sumbit, mandatory.
In the next step, create in the action.php file (or your version) and get the data, for example, in this way:
<form> <p> Имя: <?php echo $_POST['name']; ?>.</p> <p> Возраст: <?php echo $_POST['age']; ?> </p> </form> Here it is the essence of what is important that you transmit the global $_POST[] array, and all the fields with the given name in conjunction with the value, "fit" into the array and are transmitted.
When you call $_POST['name'] you will receive data that is transmitted on the first form via <input type="text" name="name" /> (the rest by analogy).
- I tried to do so, but on the page where I pass the values, nothing is displayed :( - Albert Idrisov
- @AlbertIdrisov attach both forms to the question, we will understand. - Legionary
- Actually, I tried to check the forms that you suggested as an example and the data was not transferred to another page. - Albert Idrisov
- I understood my mistake and already corrected. The second page had to be opened with the php extension, and not html, as I did. Thanks a lot for your help! - Albert Idrisov
You need to make a form that when you click on submit, sends data from the form via POST or GET as you prefer, there you catch them, for example & _POST ['name'], and for example you put them into hidden fields, on the second page you have additional fields, then you do the same thing only + new data as long as you have the logic of the page form will not reach the end.
Actually everything. Nothing complicated.