How can i pass data from one form to another form.?
-
Hello All, I want to create a Preview page which will contain the information of different forms filled by user. suppose i have three page "A.php", "B.php" and "Preview.php" OK and I am doing entry in both the pages(A as well B) OK .Now I have two button in B form which is "Back" & "Next" if a user will click on back then he/she will be able to go Form A . else if he/she press Next then they will go to Preview page . Now what code I have written for B form----- <form name="form1" method="post" action="preview.php"> <input type="text" name="formVar" value=""> <input type="submit" value="Next" > </form> and now Preview code is like that------- <?php $myvar = $_POST['formVar']; echo "Show".$myvar; ?> OK like that I am able to take the value from "B.php" into preview page but how to get the value from "A.php" because in "A.php" I cannot put action="Preview.php" in form tag. the reason is that because it is step by step process.firstly it will go A-------->Band then-----> Preview and in Preview.php i want to take the value of "A.php" as well "B.php". Thanks Shachindra Pandey
-
Answer:
c++ tutorial http://josutis.com /
sachindra p at Yahoo! Answers Visit the source
Other answers
Its a long process but it should work, you can in B.php use the $_POST method to get the values of A.php and assign them each as variables. Then in the form on B.php you can create hidden fields and set the value of these fields to <? echo""; ?> in this you should echo the values of A.php then finally in Preview.php you can use the $_POST method to get the values of these hidden fields. Hope it works, ask if you need help
You can do all of this without PHP. You just need to keep the form data from Page A in Page B and pass both Page A and Page B form data to Preview. All of that can be done in plain HTML and using Form data. If you wish to use PHP, I would recommend using session variables. These stay available to you from page to page. They exist on the server and not on the web page. You can call them while the customer uses the same session. I am not a PHP expert, but that is the type of code you need to look into. I use Session variables in ColdFusion and .NET all the time to save information from one page to another. Good luck.
stay in one page. .... you can see the highlighted version here: http://phpcode.hu/one_click_repo/?h=028b7dd2_104&bb=off start a session with <?php session_start(); ?> you've got a form: <form action="form.php" method="post" name="Form"> the submit buttons should see this: <submit name="preview" type="submit" value="preview"> <submit name="send" type="submit" value="send"> <submit name="edit" type="submit" value="edit"> how to build the textfields inputs? <?php if ( isset( $_POST["edit"] ) OR empty( $_POST["send"] ) ) { ?> <input name="value1" id="value1" type="textfield" value="<?php echo ( isset( $_SESSION["saved"]["value1"] )?htmlspecialchars( $_SESSION["saved"]["value1"] ):"" ) ?>"> <input name="value2" id="value2" type="textfield" value="<?php echo ( isset( $_SESSION["saved"]["value2"] )?htmlspecialchars( $_SESSION["saved"]["value2"] ):"" ) ?>"> </form> <?php } elseif ( !empty( $_POST["preview"] ) ) { if ( isset( $_POST["value1"] ) ) { $_SESSION["saved"]["value1"] = $_POST["value1"]; // save the posted value into a session array } if ( isset( $_POST["value2"] ) ) { $_SESSION["saved"]["value2"] = $_POST["value2"]; // save the posted value into a session array } echo "value1 is " . ( empty( $_POST["value1"] ) ? htmlspecialchars( $_POST["value1"] ) : " - " ); echo "value2 is " . ( empty( $_POST["value2"] ) ? htmlspecialchars( $_POST["value2"] ) : " - " ); } elseif ( !empty( $_POST["save"] ) ) { // save the values into database, or send with email... } ?>
You'll want to create sessions at the top of each page and declare your variables: <?php session-start(); $_SESSION['formAVar']; ?> Then on page B you'll get the '$_GET variables from page A and place each in a session variable: $_SESSION['formAVal'] = $_GET['formAVal']; ?> Then in page A write something like this to insert the value into the input when writing the form: ..form stuff... <?php if( $_SESSION['formAVal'] != "" ) { echo "<input type='text' name='formVar' value='".$_SESSION['formAVal']."'>"; } ?> ..more form stuff...
Related Q & A:
- How can I pass global variables into a function?Best solution by Stack Overflow
- How can I display data in a listview?Best solution by Stack Overflow
- How can I move bookmarks from one email to another one?Best solution by pcworld.com
- How can I transfer contacts from one phone to another?Best solution by eHow old
- How can I be allergic to one dog but not another?Best solution by verywell.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.