473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Passing form data from one web page to another web page form with PHP

There are so many examples of passing data from one page to another using GET and POST in PHP.

However what I am trying to do is a bit different.

Here is what i need to do:

I have form on one page (page1.php) and I need to pass its selected value/data as it is to another page (page2.php)
here is the code.........for page1


Expand|Select|Wrap|Line Numbers
  1.  <form id="form_1" action="page2.php" method="post">
  2.           <fieldset>
  3.             <div class="pad1">
  4.               <h3>Find Your Trip </h3>
  5.               <p>
  6.                 <label for="select">Trip Type</label>
  7.                 <select name="select4" id="select">
  8.                   <option value="choose">Choose</option>
  9.                   <option value="one way">One way</option>
  10.                   <option value="round trip">Round Trip</option>
  11.                 </select>
  12.               </p>
  13.               <div class="row_select">
  14.                 <p>From:
  15.                   <select name="select">
  16.                     <option value="" selected>:: Departure ::</option>
  17.                     <option value="36">ABBOTTABAD</option>
  18.                     <option value="6" >BAHAWALPUR</option>
  19.                     <option value="18" >CHINIOT</option>
  20.                     <option value="14" >DERA GHAZI KHAN</option>
  21.                     <option value="16" >FAISALABAD</option>
  22.                     <option value="34" >GUJRANWALA</option>
  23.                     <option value="33" >GUJRAT</option>
  24.                     <option value="53" >JHELUM</option>
  25.                     <option value="13" >KARACHI</option>
  26.                     <option value="5" >MULTAN</option>
  27.                     <option value="35" >MURREE</option>
  28.                     <option value="25" >PESHAWAR</option>
  29.                     <option value="22" >RAWALPINDI</option>
  30.                     <option value="22" >LAHORE</option>
  31.                                     </select>
  32.                 </p>
  33.                 <p>
  34.  
  35.                   To:    
  36.                     <label></label>
  37. <select name="select2">
  38.                      <option value="" selected>:: Arrival ::</option>
  39.                       <option value="36">ABBOTTABAD</option>
  40.                     <option value="6" >BAHAWALPUR</option>
  41.                     <option value="18" >CHINIOT</option>
  42.                     <option value="14" >DERA GHAZI KHAN</option>
  43.                     <option value="16" >FAISALABAD</option>
  44.                     <option value="34" >GUJRANWALA</option>
  45.                     <option value="33" >GUJRAT</option>
  46.                     <option value="53" >JHELUM</option>
  47.                     <option value="13" >KARACHI</option>
  48.                     <option value="53" >MULTAN</option>
  49.                     <option value="3" >MURREE</option>
  50.                     <option value="5" >PESHAWAR</option>
  51.                     <option value="2" >RAWALPINDI</option>
  52.                     <option value="2" >LAHORE</option>
  53.  
  54.                   </select>
  55.                   <br>
  56.                 </p>
  57.               </div>
  58.               <div class="row_select">
  59.                 <p>Arrival:<br>
  60.                   <input type="date" name="bday" max="1979-12-31">
  61.                   <br>
  62.                   Destination:                </p>
  63.                 <p>
  64.                     <input type="date" name="bday2" min="2000-01-02">
  65.                     <br>
  66.                     <span class="cols">Adult:<br>
  67.                     <select name="select3">
  68.                       <option>&nbsp;</option>
  69.                       <option>...</option>
  70.                       <option>...</option>
  71.                     </select>
  72.                     </span><br>
  73.                     <br>
  74.                     <span class="cols pad_left1"><a href="page2.php" class="button">BUY</a></span></p>
  75.               </div>
  76.               <p>&nbsp;</p>
  77.             </div>
  78.             </fieldset> 
  79.           </form>
  80.  






AND THIS IS THE CODE OF page2
Expand|Select|Wrap|Line Numbers
  1. <form id="form_1" action="#" method="post">
  2.             <div class="pad1">
  3.               <h3>Find Your Trip </h3>
  4.               <p>
  5.                 <label for="select">Trip Type</label>
  6.                 <select name="select4" id="select">
  7.                  <?php echo $_POST["select4"]; ?>!<br>
  8.                   <option value="choose">Choose</option>
  9.                   <option value="one way">One way</option>
  10.                   <option value="round trip">Round Trip</option>
  11.  
  12.                 </select>
  13.               </p>
  14.               <div class="row_select">
  15.                 <p>From:
  16.                   <select name="select">
  17.                    <?php echo $_POST["select"]; ?>!<br>
  18.                       <option value="" selected>:: Departure ::</option>
  19.                       <option value="36">ABBOTTABAD</option>
  20.                       <option value="6" >BAHAWALPUR</option>
  21.                       <option value="18" >CHINIOT</option>
  22.                       <option value="14" >DERA GHAZI KHAN</option>
  23.                       <option value="16" >FAISALABAD</option>
  24.                       <option value="34" >GUJRANWALA</option>
  25.                       <option value="33" >GUJRAT</option>
  26.                       <option value="53" >JHELUM</option>
  27.                       <option value="13" >KARACHI</option>
  28.                       <option value="5" >MULTAN</option>
  29.                       <option value="35" >MURREE</option>
  30.                       <option value="25" >PESHAWAR</option>
  31.                       <option value="22" >RAWALPINDI</option>
  32.                       <option value="22" >LAHORE</option>
  33.                     </select>
  34.                 </p>
  35.                 <p> To:
  36.                   <label></label>
  37.  
  38.                     <select name="select2">
  39.                       <?php echo $_POST["select2"]; ?>!<br>
  40.                       <option value="" selected>:: Arrival ::</option>
  41.                       <option value="36">ABBOTTABAD</option>
  42.                       <option value="6" >BAHAWALPUR</option>
  43.                       <option value="18" >CHINIOT</option>
  44.                       <option value="14" >DERA GHAZI KHAN</option>
  45.                       <option value="16" >FAISALABAD</option>
  46.                       <option value="34" >GUJRANWALA</option>
  47.                       <option value="33" >GUJRAT</option>
  48.                       <option value="53" >JHELUM</option>
  49.                       <option value="13" >KARACHI</option>
  50.                       <option value="53" >MULTAN</option>
  51.                       <option value="3" >MURREE</option>
  52.                       <option value="5" >PESHAWAR</option>
  53.                       <option value="2" >RAWALPINDI</option>
  54.                       <option value="2" >LAHORE</option>
  55.                     </select>
  56.                     <br>
  57.                 </p>
  58.               </div>
  59.               <div class="row_select">
  60.                 <p>Arrival:<br>
  61.                     <input type="date" name="bday" max="1979-12-31">
  62.                     <br>
  63.                   Destination: </p>
  64.                 <p>
  65.                   <input type="date" name="bday2" min="2000-01-02">
  66.                   <br>
  67.                   <span class="cols">Adult:<br>
  68.                   <select name="select3">
  69.                     <option>&nbsp;</option>
  70.                     <option>...</option>
  71.                     <option>...</option>
  72.                   </select>
  73.                   </span><br>
  74.                   <br>
  75.                   <span class="cols pad_left1"><a href="#" class="button">BUY</a></span></p>
  76.               </div>
  77.               <p>&nbsp;</p>
  78.             </div>
  79.           </form>
  80.  
  81.  
  82.  
  83.  
  84.  
Jun 7 '15 #1
5 1206
computerfox
276 100+
Please note that you are using the "POST" method in the form. You should be retrieving the data using POST.

Also, what's with the two different threads for the same topic?

http://bytes.com/topic/php/answers/9...-dropdown-list
Jun 7 '15 #2
when user select the value form page 1 and then by pressing submit button he moves toanother page(page2) with the selected value
Jun 7 '15 #3


like this website
Jun 7 '15 #4
computerfox
276 100+
Ummm... that page just brings me to this page....


When using POST, you need to extract the value by using POST.
When using GET, you use GET.

GET does not mean get the result from POST, the same way that POST doesn't means to put the data.

When forms first came out, we used the GET method. which uses the url and sets the values using ?field=value. We then got that value by using the GET[field].

Now, we have post, which we use the same way, but is a lot safer. These are very basic concepts.
Jun 7 '15 #5
http://www.renganathan.in/
...........i want to do like in this website when user select the value from (to) and (from )dropdown list and also select deperature and return from this page then he moves to the next page ........and dropdownlist in next page are automatically populated with the value selected by the user in first page..........
so my question is that how dropdownlist in second page are displayed.........
Jun 8 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: viktor | last post by:
Hi , I have a small problem.How can I pass value from form thru a few pages. I try with hidden field but my second page just validate and redirect to other one and when I use...
9
by: sifar | last post by:
Hi, I am right now learning PHP & want to know if there is a way to send web form data to an Excel sheet located on a network. My windows xp PC doesnot have a copy of Excel. Also i am not...
4
by: Miguel Dias Moura | last post by:
Hello, i created an ASP.net / VB page with a really big form. Now i want to create 4 pages and in each one i will place 1/4 of the big form. The last page will send all the form values by...
2
by: Bob [BVP] | last post by:
I have a need to pass hidden form data on a Aspx form to a plain vanilla Asp page.. with it remaining hidden, and not using session/state cludges.. Thanks for any info. Bob
4
by: Andrea De Santi | last post by:
How can I redirect to another page with form data? In asp Classic I write: <form ... action="filename">...</form> and in then target page I write <%=request.form("fieldname")%> ..... but in...
4
by: Vasantha peddireddy | last post by:
I am posting a page to another page (form post). The data grid on the second page is being populated with data. Now, on page load of the second page, I would like to send the grid data on this page...
6
by: Kausar | last post by:
Hello All, How do i pass the value from a page that exists on some domain to another page that exists in subdomain. Regards Kausar
1
by: mentor | last post by:
in first page, <form id="form1" runat="server" action="page2.aspx"> <TEXTAREA id="txt1" runat=server></TEXTAREA> <INPUT type=submit value=submit name=rev_submit> in second page(c#) string...
2
by: Hamayun Khan | last post by:
Hi I have Two pages Default.aspx and Default2.aspx Default.aspx has the following code <%@ Page Language="VB" MasterPageFile="~/Main.master" AutoEventWireup="false"...
1
by: sushma reddy | last post by:
i am a fresher to html,css and java script. i am creating a main html page with the tile main.html , it contains a search box. then i am linking this to another web page(sub.html) which contains a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.