TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-21-2010, 12:25 AM   #1 (permalink)
The Wanderer
 
Join Date: Mar 2010
Posts: 14
Thanks: 4
fairytale89 is on a distinguished road
Default can i insert value from another page into next page query

i have 2 forms here.
1) DisplayDetails.php
2) RegistrationForm.php

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

so, at the RegistrationForm, 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
RegistrationForm.php page query so that i can insert the value into database.

below is the code for DisplayDetails.php

Code:
<?php
session_start();
//echo "<pre>";
//var_dump($_SESSION);
//echo "</pre>"; 

$id_no=$_GET['id_no'];


$query="SELECT * from room1 WHERE id_no=$id_no";

$result=mysql_query($query);

//Get the number of rows in array for loop
$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {
$id_no=mysql_result($result,$i,"id_no");
$room_no=mysql_result($result,$i,"room_no");
$room_type=mysql_result($result,$i,"room_type");
$qty=mysql_result($result,$i,"qty");
$room_price=mysql_result($result,$i,"room_price");

//echo "$id_no - $room_no - $room_type - $qty - $rom_price";

$i++;
} 

?>

<body>
<h3><center>
   Room's Reservation
</center></h3>
<form action="DisplayDetails.php" method="post">

  <table width="373" border="1">
    <tr>
      <td colspan="2"><strong>Reservation Summary</strong></td>
    </tr>
    <tr>
      <td>Check In :</td>
      <td><label> <?php echo $_SESSION['checkin']; ?> </label></td>
    </tr>
    <tr>
      <td>Check Out :</td>
      <td><label><?php echo $_SESSION['checkout']; ?></label></td>
    </tr>
    <tr>
      <td>Rooms :</td>
      <td><label><?php echo $_SESSION['rooms']; ?></label></td>
    </tr>
    <tr>
      <td>Adults Per Room :</td>
      <td><label><?php echo $_SESSION['adults']; ?></label></td>
    </tr>
    <tr>
      <td>Children Per Room :</td>
      <td><label><?php echo $_SESSION['children']; ?></label></td>
    </tr>
    <tr>
      <td>Days :</td>
      <td><?php echo $_SESSION['days']; ?></td>
    </tr>
    <tr>
      <td>Room Type</td>
      <td><?php echo $room_type; ?></td>
    </tr>
    <tr>
      <td>Room Price</td>
      <td><?php echo $room_price; ?></td>
    </tr>
    <tr>
      <td>TOTAL PRICE :</td>
      <td><?php $total =$_SESSION['days'] * $room_price;
  		echo $total;?>        </td>
    </tr>
  </table>  
  <label>
  <input type="submit" name="submit" id="submit" value="submit" />
  </label>
  <a href="RegistrationForm.php"><strong> 
  Next &gt;&gt; </strong></a>
</form>
</body>
</html>
below is the code for RegistrationForm.php

Code:
<?php
session_start();
?>
<html>
<body>

 <form action="RegistrationForm.php" method="post">
 
 <p><strong>REGISTRATION FORM</strong></p>

 <table width="285" border="1">
   <tr>
     <th width="120" scope="row">Name :</th>
     <td width="149"><label>
      <input type="text" name="name" id="name" value="<?php $name; ?>"/>
     </label></td>
   </tr>
   <tr>
     <th scope="row">Ic No :</th>
     <td><label>
       <input type="text" name="ic_no" id="ic_no" value="<?php $ic_no; ?>">
     </label></td>
   </tr>
   <tr>
     <th scope="row">Contact No :</th>
     <td><label>
       <input type="text" name="contact_no" id="contact_no" value="<?php $contact_no; ?>">
     </label></td>
   </tr>
   <tr>
     <th scope="row">Email :</th>
     <td><label>
       <input type="text" name="email" id="email" value="<?php $email; ?>">
     </label></td>
   </tr>
   <tr>
     <th scope="row">Gender :</th>
     <td><label>
       <select name="gender" id="gender" value="<?php $gender; ?>">
         <option>female</option>
         <option>male</option>
      </select>
     </label></td>
   </tr>
   <tr>
     <th scope="row">Username :</th>
     <td><label>
       <input type="text" name="username" id="username" value="<?php $username; ?>">
     </label></td>
   </tr>
   <tr>
     <th scope="row">Password :</th>
     <td><label>
       <input type="text" name="password" id="password" value="<?php $password; ?>">
     </label></td>
   </tr>
 </table>
 <p>
 </p>
 <p>
   <label>
   <input type="submit" name="submit" id="submit" value="Submit">
   </label>
   
      <?php


$room_type=$_POST['room_type'];

$sql="INSERT INTO reservation1 
(name,ic_no, gender,checkin,checkout,
room_type)
VALUES
('$_POST[name]','$_POST[ic_no]','$_POST[gender]','$_SESSION[checkin]','$_SESSION[checkout]',
'$_POST[room_type]')";
?>

 </p>
</form>

</body>
</html>
fairytale89 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
help on making my own crawler webtuto General 16 08-08-2009 08:55 AM
Query With a C# Variable?‏ StevenF The Lounge 5 12-08-2008 05:32 AM
Insert data into two tables with one query CMellor MySQL & Databases 5 12-10-2007 10:46 AM
Extracting page titles and placing into dropdown box. Dorza General 6 10-29-2007 11:01 PM


All times are GMT. The time now is 11:06 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design