473,545 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can i insert value from another page into next page query

17 New Member
i have 2 forms here.
1) DisplayDetails. php
2) RegistrationFor m.php

when user click to the link 'Next' at the DisplayDetails. php page it will bring
all the session value to the RegistrationFor m.php page. But, there's also value which is not session which is
i) $room_type

so, at the RegistrationFor m, i wanted to passed all the values from the DisplayDetails. php into mysql query
to insert into database.After i test it, all the data work fine including the session values from DisplayDetails. php.
The only problem is, value which is i) $room_type
that i got from the query in the DisplayDetails. php as the only that
unsuccessfully inserted into the database.

So, the question is, is it possible for me to get value from the DisplayDetails. php page into
RegistrationFor m.php page query so that i can insert the value into database.

below is the code for DisplayDetails. php

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. session_start();
  4. //echo "<pre>";
  5. //var_dump($_SESSION);
  6. //echo "</pre>"; 
  7.  
  8. $id_no=$_GET['id_no'];
  9.  
  10.  
  11. $query="SELECT * from room1 WHERE id_no=$id_no";
  12.  
  13. $result=mysql_query($query);
  14.  
  15. //Get the number of rows in array for loop
  16. $num=mysql_numrows($result);
  17.  
  18. mysql_close();
  19.  
  20. $i=0;
  21. while ($i < $num) {
  22. $id_no=mysql_result($result,$i,"id_no");
  23. $room_no=mysql_result($result,$i,"room_no");
  24. $room_type=mysql_result($result,$i,"room_type");
  25. $qty=mysql_result($result,$i,"qty");
  26. $room_price=mysql_result($result,$i,"room_price");
  27.  
  28. //echo "$id_no - $room_no - $room_type - $qty - $rom_price";
  29.  
  30. $i++;
  31.  
  32. ?>
  33.  
  34. <body>
  35. <h3><center>
  36.    Room's Reservation
  37. </center></h3>
  38. <form action="DisplayDetails.php" method="post">
  39.  
  40.   <table width="373" border="1">
  41.     <tr>
  42.       <td colspan="2"><strong>Reservation Summary</strong></td>
  43.     </tr>
  44.     <tr>
  45.       <td>Check In :</td>
  46.       <td><label> <?php echo $_SESSION['checkin']; ?> </label></td>
  47.     </tr>
  48.     <tr>
  49.       <td>Check Out :</td>
  50.       <td><label><?php echo $_SESSION['checkout']; ?></label></td>
  51.     </tr>
  52.     <tr>
  53.       <td>Rooms :</td>
  54.       <td><label><?php echo $_SESSION['rooms']; ?></label></td>
  55.     </tr>
  56.     <tr>
  57.       <td>Adults Per Room :</td>
  58.       <td><label><?php echo $_SESSION['adults']; ?></label></td>
  59.     </tr>
  60.     <tr>
  61.       <td>Children Per Room :</td>
  62.       <td><label><?php echo $_SESSION['children']; ?></label></td>
  63.     </tr>
  64.     <tr>
  65.       <td>Days :</td>
  66.       <td><?php echo $_SESSION['days']; ?></td>
  67.     </tr>
  68.     <tr>
  69.       <td>Room Type</td>
  70.       <td><?php echo $room_type; ?></td>
  71.     </tr>
  72.     <tr>
  73.       <td>Room Price</td>
  74.       <td><?php echo $room_price; ?></td>
  75.     </tr>
  76.     <tr>
  77.       <td>TOTAL PRICE :</td>
  78.       <td><?php $total =$_SESSION['days'] * $room_price;
  79.           echo $total;?>        </td>
  80.     </tr>
  81.   </table>  
  82.   <label>
  83.   <input type="submit" name="submit" id="submit" value="submit" />
  84.   </label>
  85.   <a href="RegistrationForm.php"><strong> 
  86.   Next &gt;&gt; </strong></a>
  87. </form>
  88. </body>
  89. </html>
  90.  
  91.  
below is the code for RegistrationFor m.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. ?>
  4. <html>
  5. <body>
  6.  
  7.  <form action="RegistrationForm.php" method="post">
  8.  
  9.  <p><strong>REGISTRATION FORM</strong></p>
  10.  
  11.  <table width="285" border="1">
  12.    <tr>
  13.      <th width="120" scope="row">Name :</th>
  14.      <td width="149"><label>
  15.       <input type="text" name="name" id="name" value="<?php $name; ?>"/>
  16.      </label></td>
  17.    </tr>
  18.    <tr>
  19.      <th scope="row">Ic No :</th>
  20.      <td><label>
  21.        <input type="text" name="ic_no" id="ic_no" value="<?php $ic_no; ?>">
  22.      </label></td>
  23.    </tr>
  24.    <tr>
  25.      <th scope="row">Contact No :</th>
  26.      <td><label>
  27.        <input type="text" name="contact_no" id="contact_no" value="<?php $contact_no; ?>">
  28.      </label></td>
  29.    </tr>
  30.    <tr>
  31.      <th scope="row">Email :</th>
  32.      <td><label>
  33.        <input type="text" name="email" id="email" value="<?php $email; ?>">
  34.      </label></td>
  35.    </tr>
  36.    <tr>
  37.      <th scope="row">Gender :</th>
  38.      <td><label>
  39.        <select name="gender" id="gender" value="<?php $gender; ?>">
  40.          <option>female</option>
  41.          <option>male</option>
  42.       </select>
  43.      </label></td>
  44.    </tr>
  45.    <tr>
  46.      <th scope="row">Username :</th>
  47.      <td><label>
  48.        <input type="text" name="username" id="username" value="<?php $username; ?>">
  49.      </label></td>
  50.    </tr>
  51.    <tr>
  52.      <th scope="row">Password :</th>
  53.      <td><label>
  54.        <input type="text" name="password" id="password" value="<?php $password; ?>">
  55.      </label></td>
  56.    </tr>
  57.  </table>
  58.  <p>
  59.  </p>
  60.  <p>
  61.    <label>
  62.    <input type="submit" name="submit" id="submit" value="Submit">
  63.    </label>
  64.  
  65.       <?php
  66.  
  67.  
  68. $room_type=$_POST['room_type'];
  69.  
  70. $sql="INSERT INTO reservation1 
  71. (name,ic_no, gender,checkin,checkout,
  72. room_type)
  73. VALUES
  74. ('$_POST[name]','$_POST[ic_no]','$_POST[gender]','$_SESSION[checkin]','$_SESSION[checkout]',
  75. '$_POST[room_type]')";
  76. ?>
  77.  
  78.  </p>
  79. </form>
  80.  
  81. </body>
  82. </html>
  83.  
  84.  
Mar 21 '10 #1
2 3185
Mayur2007
67 New Member
Hello,

I had look over your code and think that you have make mistake in DisplayDetails. php line number 18. mysql_close(); which should be end of the page. Also there is no database connection in RegistrationFor m.php. Also you have not assign room_type to session or retrieve it from session make sure for that.

Regards,
Mayur Bhayani
Mar 30 '10 #2
digituf
17 New Member
Thanks Mayur2007. your comment did really help me. I already solved the problems..thank z for spending time to check my code..:)
Mar 30 '10 #3

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

Similar topics

2
2924
by: lawrence | last post by:
A very strange bug. www.monkeyclaus.org is run by a cms I'm developing. One of types of users we allow is "justTestingTheSite", a type of user I developed to give demo's to prospective clients. The purpose of this level of security is to let someone log in and see everything as if they were root, and yet not be able to update or delete...
3
13209
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax: Hunter_69. Here is what the form looks like. I have the difficulty of inserting the multiple items selected by the user the first time he visits and uses...
10
3208
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it into another table on a remote server. The below code only inserts 1 record. How do I change the code to get all records inserted? thanks! <% Dim...
1
8731
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware tblSoftware ------------------- ------------------ ---------------------- PID PName PID* SID* SID SWName --- ...
2
3174
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request : INSERT INTO temp_tab VALUES (1,2,3)
5
4058
by: robecflo | last post by:
Hi Forum, i have a problem, hope somebody can give me ideas. I'm developing with windows forms and vb.net, and oracle as a database. At this moment i have a table called amortizaciones, this table has a field called id_pasivo, which is foreign key to another table called pasivo, a consecutive field called no_cupon and a third field called...
7
7208
by: underground | last post by:
I wonder if possible on page load to query the value of a specific colmn and insert the result into another table. My query looks like so <? include("include/session.php"); ?> <? $usr = "xxxx"; $pwd = "xxxxx"; $db = "xxxxx";
6
3444
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns,...
4
3116
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I can speed up the processing substantially? as it currently takes about 10 minutes and thats just way too long because there is many of these imports...
2
9422
by: rn5a | last post by:
In a ASP applicatiuon, the FOrm has a textbox & a select list where the admin can select multiple options. Basically the admin has to enter the name of a new coach in the textbox & select the soccer clubs which he will be coaching; thus he can select only one soccer club for a new coach or multiple soccer clubs. This is how I am trying it:...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
6009
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...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
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
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
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
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.