passing a value form one form


#1

I have a page index.php where i have my datepicker.

[php]

<form method="post" action="insertionform.php" name="index" onSubmit="return validateForm()">
Pick Up Date :

Drop off date :

  <BR />
  <input name="" type="submit" value="Check Availability" id="button" /></td></tr></table>

[/php]

It will pass the date values to the nxt page which is the insertionform.php

[php]

<?php $confirmation_code=md5(uniqid(rand())); $pickupdate = $_POST['pickup']; $dropoffdate = $_POST['dropoff']; ?>
       <form method="post" name="form1" action="Other_details.php" onSubmit="return validateForm()">
         <table align="center">
           <tr valign="baseline">
             <td nowrap align="right">Fullname:</td>
             <td><input type="text" name="fullname" value="" size="32"></td>
           </tr>
           <tr valign="baseline">
             <td nowrap align="right">Phone No.:</td>
             <td><input type="text" name="telnum" value="" size="32"></td>
           </tr>
           <tr valign="baseline">
             <td nowrap align="right">Address:</td>
             <td><input type="text" name="address" value="" size="32"></td>
           </tr>
           <tr valign="baseline">
             <td nowrap align="right">Sex:</td>
             <td><select name="sex">
                 <option value="Female" <?php if (!(strcmp("Female", ""))) {echo "SELECTED";} ?>>Female</option>
                 <option value="Male" <?php if (!(strcmp("Male", ""))) {echo "SELECTED";} ?>>Male</option>
               </select>
             </td>
           </tr>
           <tr valign="baseline">
             <td nowrap align="right">Email:</td>
             <td><input type="text" name="email" value="" size="32"></td>
           </tr>
           <tr valign="baseline">
             <td nowrap align="right">&nbsp;</td>
             <td><input type="submit" value="Insert record"></td>
           </tr>
         </table>
         <input type="hidden" name="confirm_code" value="<?php echo $confirmation_code;?>">
         <input type="hidden" name="pickup" value="<?php echo $pickupdate;?>">
         <input type="hidden" name="dropoff" value="<?php echo $dropoffdate;?>">
         <input type="hidden" name="MM_insert" value="form1">
       </form>
       <?php
	   }
	   ?>

[/php]

The action in insertionform.php is custsave.php where the execeution of insertion happens.
[php]

<?php $confirmation_code=$_POST['confirm_code']; $pickupdate=$_POST['pickup']; $dropoffdate=$_POST['dropoff']; $fullname=$_POST['fullname']; $telnum=$_POST['telnum']; $address=$_POST['address']; $sex=$_POST['sex']; $email=$_POST['email']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("records", $con); $sql="INSERT INTO tblcust (confirm_code,Fullname,telnum,address,sex,email) VALUES ('$confirmation_code','$fullname','$telnum','$address','$sex','$email')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } header("Other_details.php"); mysql_close($con) ?>

[/php]

So after insertion it will go to Other_details.php

[php]

<?php include('db.php'); include('func.php'); $pickupdate=$_POST['pickup']; $dropoffdate=$_POST['dropoff']; ?>
     <h2>Reservation Details</h2>

Truck Type :

  <option value="" selected="selected" disabled="disabled">Select a Truck Type</option>
  
  <?php getTierOne(); ?>

</select>
</td>

<span id="wait_1" style="display: none;">
<img src="three-tier/ajax-loader.gif" alt="Please Wait...">
</span>



"> ">

</div>

[/php]

and the PROBLEM is i can’t get the value of the pick up date and drop off date, so what is the simplest possible solution for this. I’m looking forward for your help immediately.


#2

Is there code or something missing from insertion form? There’s a } at the end of it that doesn’t have a corresponding { on top.

You have the pickup and dropfield fields marked readonly with empty values, so there’s nothing but empty space to pass between the forms. Put a date in there and it should work :slight_smile:


#3

You are also setting the value to nothing. ( value="" ) So, nothing would be sent back as it is readonly, can’t be writen to and starts with nothing. So, only nothing can be sent to the next page.

Why readonly if you are going to change it?