In one PHP, I defined two forms, and when the first form was submitted, a second form was generated, and after the second form was submitted, the data for the first form was not taken, what should I do?

Source: Internet
Author: User
form PHP Submission Pass data

In one PHP, I defined two forms, and when the first form was submitted, a second form was generated, and after the second form was submitted, the data for the first form was not taken, what should I do?
First form
echo "";//a second form
Var_dump ($m);
?>
The second time after the submission will not be $m, what can be done to pass $m to the last?
I am novice, do not know the cookie, session. Thanks, man.


Reply to discussion (solution)

The most reasonable way to do this is to use the session or cookie to save the previous submission, do not understand the words simply take this as an opportunity to learn

The most reasonable way to do this is to use the session or cookie to save the previous submission, do not understand the words simply take this as an opportunity to learn
Well, I learned temporarily, my practice is that two forms are placed in two PHP files, and then in the second PHP wrote Setcookie ("M1", $m, Time () +3600);
$m 2=$_cookie["M1"];
Then I'll use M2 as the value of M, but when I'm ready to generate a third form, how do I get m? I think PHP will not get the previous PHP value after jumping to the next page. Can you solve this problem with XML?

Don't make things so complicated.
Your second form is a handler for the first form created
Then put the submission of the first form into the second form in the form of a hidden variable.

Don't make things so complicated.
Your second form is a handler for the first form created
Then put the submission of the first form into the second form in the form of a hidden variable.
I also think so, but do not hide the variable ah, I hope there is code reference, thank you!

Don't make things so complicated.
Your second form is a handler for the first form created
Then put the submission of the first form into the second form in the form of a hidden variable.
He this kind of demand I met a long time ago, is to do a questionnaire survey one page?? After the answer to the next problem, the first is to do hidden, and then found that more than 10 problems are too troublesome, with the session instead of a lot easier

Cookie I also feel trouble, if using a cookie to simply do "fake submit", once the problem is sent over, with JS to hide behind the problem, display, to the last question to submit

The disadvantage of the session is time-sensitive, need to be in a certain period of action in order not to lose value
The disadvantage of cookies is that clients can fake

Add PHP code to the room
foreach ($_post as $k = $v) echo "";

How can it be trouble? Use the session's form page, no matter how to set, "fallback" performance is unsatisfactory



Don't make things so complicated.
Your second form is a handler for the first form created
Then put the submission of the first form into the second form in the form of a hidden variable.
I also think so, but do not hide the variable ah, I hope there is code reference, thank you!


Don't make things so complicated.
Your second form is a handler for the first form created
Then put the submission of the first form into the second form in the form of a hidden variable.
He this kind of demand I met a long time ago, is to do a questionnaire survey one page?? After the answer to the next problem, the first is to do hidden, and then found that more than 10 problems are too troublesome, with the session instead of a lot easier

Cookie I also feel trouble, if using a cookie to simply do "fake submit", once the problem is sent over, with JS to hide behind the problem, display, to the last question to submit

The disadvantage of the session is time-sensitive, need to be in a certain period of action in order not to lose value
The disadvantage of cookies is that clients can fake
No, the form I'm generating is based on the previous form submission data to use, no output cap, hidden.

The same, JS can be based on the "commit" content generation control, but you are not familiar with it

I can not do it according to the method of the old Xu, this idea is the simplest

I am relatively familiar with the group, so accustomed to the session record, lazy every time the data submitted before the previous traversal

You can do that. Two ways
One way is to split the two pages: after the first step is submitted, the second step is read out.
Two steps in a page: first with JS Hidden second step, Ajax commit, then the second step can also get the value of the first step.

Don't make things so complicated.
Your second form is a handler for the first form created
Then put the submission of the first form into the second form in the form of a hidden variable.
Well, I think this method is the most convenient, but no results, you look at my code?
This is the second PHP:
foreach ($_post as $k = $v)
{
echo "";
}
Var_dump ($m);
echo "";
?>
This is a third PHP:
foreach ($_post as $k = $v)
{
echo "";
}
$n;
for ($i =1; $i <= $m; $i + +)
{
$h = "n". $i;
$n []=$_post["$h"];
}
Var_dump ($n);
?>
Jump to the third PHP output is null, the URL is only followed N1, N2, N3 ... The value, does not appear m, what's going on?

The same, JS can be based on the "commit" content generation control, but you are not familiar with it

I can not do it according to the method of the old Xu, this idea is the simplest

I am relatively familiar with the group, so accustomed to the session record, lazy every time the data submitted before the previous traversal
Thank you! But I use the 6# above the code still can not come out the result, what is going on?

Placed in

What's the use of the outside?

What's the use on the outside?
That's good! There is a white write for one months PHP feeling, and I also found that my code inside get and post are not matched, thank you very much!

I want to knot, this is the first time I posted on the csdn, ask PHP related issues, did not expect the effect is very good, although seriously despise their IQ, but can learn something I am very grateful, Later I also learn to learn cookies and session, thank xuzuning, snmr_com!
@xuzuning
@snmr_com
Scatter the flowers! O (∩_∩) o

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.