In a php file, I define two forms. when the first form is submitted, the second form is generated. after the second form is submitted, the data of the first form cannot be obtained, what should I do? Form php submit transfer data
In a php file, I define two forms. when the first form is submitted, the second form is generated. after the second form is submitted, the data of the first form cannot be obtained, what should I do?
// The first form
Echo ""; // The second form
Var_dump ($ m );
?>
After the second submission, $ m is not available. how can we pass $ m to the end?
I am a newbie and do not know cookie or session. Thank you!
Reply to discussion (solution)
The most reasonable practice is to save the previous submission with session or cookie. if you don't understand it, simply take this opportunity to learn.
The most reasonable practice is to save the previous submission with session or cookie. if you don't understand it, simply take this opportunity to learn.
Well, I learned it temporarily. my practice is to put two forms in two php files, and then write setcookie ("m1", $ m, time () in the second php file () + 3600 );
$ M2 = $ _ COOKIE ["m1"];
Then I use the variable m2 as the value of m, but how can I get m when I prepare to generate the third form? I don't think the value of the previous php can be obtained after php jumps to the next page. Can xml be used to solve this problem?
Don't make things so complicated
Your second form is created by the first form handler.
Put the submission of the first form in the form of hidden variables in the second form.
Don't make things so complicated
Your second form is created by the first form handler.
Put the submission of the first form in the form of hidden variables in the second form.
I think so too, but it does not hide variables. I hope you can refer to the code. thank you!
Don't make things so complicated
Your second form is created by the first form handler.
Put the submission of the first form in the form of hidden variables in the second form.
I have met this kind of requirement a long time ago, that is, when I do a questionnaire survey, a question page ?? After the answer, the next question appeared. at first, it was carried out one by Hiden. later, it was found that a dozen questions were too troublesome. Instead, it was much easier to use sessions.
I am also in trouble with cookies. if I use cookies, I will simply make "fake submissions" and send all the questions at one time. I will use js to hide the questions and display them one by one, submitted together with the last question
The disadvantage of a session is that it is time-sensitive and requires action at a certain time so that the value will not be lost.
The disadvantage of cookie is that the client can be fake.
Add php code
Foreach ($ _ POST as $ k => $ v) echo"";
How can this problem be solved? When a single page of a session table is used, no matter how you set it, the performance of "rollback" is unsatisfactory.
Don't make things so complicated
Your second form is created by the first form handler.
Put the submission of the first form in the form of hidden variables in the second form.
I think so too, but it does not hide variables. I hope you can refer to the code. thank you!
Don't make things so complicated
Your second form is created by the first form handler.
Put the submission of the first form in the form of hidden variables in the second form.
I have met this kind of requirement a long time ago, that is, when I do a questionnaire survey, a question page ?? After the answer, the next question appeared. at first, it was carried out one by Hiden. later, it was found that a dozen questions were too troublesome. Instead, it was much easier to use sessions.
I am also in trouble with cookies. if I use cookies, I will simply make "fake submissions" and send all the questions at one time. I will use js to hide the questions and display them one by one, submitted together with the last question
The disadvantage of a session is that it is time-sensitive and requires action at a certain time so that the value will not be lost.
The disadvantage of cookie is that the client can be fake.
No, the form I generated can only be used to submit data based on the previous form. there is no output limit, and hidden is not supported.
Similarly, js can also generate controls based on "submitted" content, but you are not familiar with them.
If you are not sure, follow the #6 method. this is the simplest idea.
I am personally familiar with arrays, so I am used to using session records, so I am too lazy to traverse the previously submitted data every time.
You can. Two methods
One method is to split the page into two parts: After the first step is submitted, it will be read at the second step.
Two steps on one page: hide step 2 with js and submit with ajax. Then, step 2 can get the value of step 1.
Don't make things so complicated
Your second form is created by the first form handler.
Put the submission of the first form in the form of hidden variables in the second form.
Well, I think this method is the most convenient, but there is no result. can you check my code?
This is the second php:
Foreach ($ _ POST as $ k => $ v)
{
Echo"";
}
Var_dump ($ m );
Echo "";
?>
This is the third php:
Foreach ($ _ POST as $ k => $ v)
{
Echo"";
}
$ N;
For ($ I = 1; $ I <= $ m; $ I ++)
{
$ H = "n". $ I;
$ N [] = $ _ POST ["$ h"];
}
Var_dump ($ n );
?>
To jump to the third php, the output is null, and the URL is only followed by the values of n1, n2, n3.. m does not appear. why?
Similarly, js can also generate controls based on "submitted" content, but you are not familiar with them.
If you are not sure, follow the #6 method. this is the simplest idea.
I am personally familiar with arrays, so I am used to using session records, so I am too lazy to traverse the previously submitted data every time.
Thank you! But I use 6 # The above code or response to get the result. what is going on?
Put in
What's the use outside?
Put inWhat's the use outside?
That's good! There is a feeling of white writing php for a month, and I also found that the get and post in my code do not match, thank you very much!
I am about to close the building. this is the first time I posted a post on csdn and asked questions related to php. I did not expect the results to be very good. although I seriously despise my IQ, however, I am very grateful for what I can learn. I will also learn cookie and session later. I am very grateful to xuzuning and snmr_com!
@ Xuzuning
@ Snmr_com
Spread flowers! O (Partition _ partition) O