473,549 Members | 3,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

14 New Member
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.........fo r 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 1220
computerfox
276 Contributor
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
rose merry
14 New Member
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
rose merry
14 New Member


like this website
Jun 7 '15 #4
computerfox
276 Contributor
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
rose merry
14 New Member
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
1485
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 Request.Form("field") it's nothing coming back. Any help please. thanks
9
4269
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 connected to the internet, its a local computer. What i am trying to do is to make a PHP script which will send a simple form data to an excel sheet...
4
1778
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 email. How can i send the form values from one page to the next one?
2
4125
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
3430
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 ASP.NET 1.1 'action' does not exist how can I send form data to another page?... and how can I read a form values (same of ASP classic with...
4
2317
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 to the first page and populate the grid on the first page with the same data on second page. Please let me know how can I do this. Thanks,...
6
2020
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
1276
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 str = Request.Form; In this way, data can be posted to second page. But I found when the first page is posted back, the content in browser is still...
2
1325
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" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
1
1358
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 search box and other stuffs. now i want the data entered in main.html to be passed as value to the search box in the sub.html. how can i do it?
0
7520
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7718
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6041
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.