Jump to content


Photo

still probs with booking query..sorry!


  • Please log in to reply
8 replies to this topic

#1 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 01 May 2006 - 07:53 PM

hey
im still having problems trying to get my code working for a booking query that i am trying 2 do
the booking is for holiday accommodation and the accommodation is searched for the the first page with details from an accommodation table which has the primary key accommID.
then from those results a radio button is chosen to carry on with the booking for that accommodation. on this booking page the users need to put in the booking start date and booking end date which is to be stored in the booking table.
the booking table has bookingID as the primary key and the accommID as a foreign key to link the to accommID's.
but what i am having problems with is storing the accommID that corresponds to the accomm chosen in the booking table.
i have tried to use hidden fields but it doesnt seem to work!
the following code is for the search results page:
i know i have used the hidden field twice but im not sure where it shud go, ive tried it in both places and it still doesnt work

$self = $_SERVER['PHP_SELF'];
$accommID = $_POST["accommID"];
$type = $_POST["select_type"];
$sleeps = $_POST["select_sleeps"];
$board = $_POST["select_board"];
$description = $_POST["description"];
$pets_allowed = $_POST["select_pets_allowed"];


//$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type = '$type' AND sleeps = '$sleeps' AND board = '$board' AND description= '$description' AND pets_allowed = '$pets_allowed'";
$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed'";
$result = mysql_query ($query) or die(mysql_error());

$num = mysql_num_rows($result);

if ($num > 0){
             echo "<p>There is currently $num accommodation(s). </p>\n";
              echo '<FORM METHOD="POST" ACTION="add_book.php">';
              echo '<table align = "center" border = "1" cellspacing = "0" cellpadding = "5">
              <tr>
              <td align="left"><b>Type</b></td>
              <td align="left"><b>Sleeps</b></td>
              <td align="left"><b>Board</b></td>
              <td align="left"><b>Description</b></td>
              <td align="left"><b>Pets Allowed</b></td>
              <input type="hidden" name="accommID" value="'.$accommID.'">
              </tr>
              ';
              
              while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
                echo '
              <tr>
              <td align="left">'. $row['type']. '</td>
              <td align="left">'. $row['sleeps']. '</td>
              <td align="left">'. $row['board']. '</td>
              <td align="left">'. $row['description']. '</td>
              <td align="left">'. $row['pets_allowed']. '</td>
              <td align=center><input type=radio name=accommID value="'.$row['accommID'].'"></td>
              </tr>
              ';
              }

              echo '</table>';
              echo '&nbsp';
              echo '<center> <input type="submit" value="Continue Booking"></center>';
              
              mysql_free_result($result);
              

              } else {

                  echo '<p class = "error">There are currently no types of accommodation for the choices entered.</p>';
              }

              echo '<input type="hidden" name="accommID" value="'.$accommID.'">';
              echo '</FORM>';

              mysql_close();



and the code for the booking looks like:

 $accommID = $_POST ["accommID"];
         $book_start = $_POST ["booking_start_date"];
         $book_end = $_POST ["booking_end_date"];

         $query = "INSERT INTO booking (booking_start_date, booking_end_date, accommID) VALUES ('$book_start','$book_end','$accommID')";

         mysql_query($query, $connection) or die (mysql_error());



thanks

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 02 May 2006 - 03:15 AM

Well first off you are passing the variable name twice in the same form.
No need for this one
<input type="hidden" name="accommID" value="'.$accommID.'">
Just use this one
<td align=center><input type=radio name=accommID value="'.$row['accommID'].'"></td>

Also if you do not know the accomID why are you setting it at the start of the page.
$accommID = $_POST["accommID"];

You also have not pulled the accomID out of the table.

incorrect
$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed'";

correct
$query = "SELECT accommID, type, sleeps, board, description, pets_allowed FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed'";

Have to select the accomID so you can pass it from the radio button
<td align=center><input type=radio name=accommID value="'.$row['accommID'].'"></td>

try those changes and let me know

Ray




#3 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 May 2006 - 11:07 AM

hey!!

thank u!! ur a genius! it works finally!!!

thanks again

puja

#4 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 May 2006 - 11:25 AM

hi again

now im having a different prob with it, after u did ur suggested changes it does put in the accommID but it puts the accommID on one record with empty dates and it puts the dates chosen by the user in a separate record with an empty acommID

#5 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 02 May 2006 - 02:31 PM

OK first thing I see is that you have no place to put in the dates, unless they are coming in from a previous page, in which case you have not passed them on to the query.

if $booking_start_date and $booking_end_date are coming from a previous page then you need to add a couple hidden values.

Add the hidden values after:
if ($num > 0){

If they are not then you need to add some form fields for them and make sure you name them booking_start_date and booking_end_date

Ray







#6 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 May 2006 - 02:59 PM

hey
the booking start and end dates are coming from that booking page not the search page.
so on the booking page where the query is there is this further down in the page:


<form action ="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">
    <p align="center">&nbsp;</p>
    <p align="center"><u>Booking Start Date:</u>&nbsp;&nbsp;&nbsp; <input type="text" name="booking_start_date" size="20"></p>
    <p align="center"><u>Booking End Date:</u>&nbsp;&nbsp;&nbsp; <input type="text" name="booking_end_date" size="20"></p>
    <p>&nbsp;</p>
    <p><input type="submit" value="Submit"></p>
  </form>

also i havnt got the accommID going thru any of my pages as a hidden field.
on my initial search page i just have the drop down lists for the choices and then on the search results page i have got the accommID hopefully going thru with the radio button and then on the booking script i havnt specified newhere that it is the accommID that was selected in the radio button.
or should it already know that coz i passed it thru with the radio button?

#7 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 03 May 2006 - 04:52 PM

if you could post the code for each page, with the page name I can better help you out. Or PM me the code.

Ray

#8 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 03 May 2006 - 06:37 PM

ok i'll post the code on here for all three of the pages i am trying to link
i know the code isnt very good but i just need to try and get the functionality working
thanks 4 ur help!

search2.php


<html>
<head>
<title><?php echo "Search" ?></title>
<link rel="stylesheet" type="text/css" href="template2.css">
<head>
<body>

<?

session_start();
if(!isset($_SESSION[user_name])) { echo "<p><center>Please login to view this page.</p><p>&nbsp;</p> Please wait... You will automatically be redirected back to the login page";
echo "<META HTTP-EQUIV=Refresh CONTENT='3; URL=gen_homepage.php'>";

} else {

require_once("config.php");
     $connection = @mysql_connect($db_host, $db_user, $db_password) or die("oops! error connecting");
     
     mysql_select_db($db_name, $connection);
?>

<table border="1" width="100%" height="226">
  <tr>
    <td width="22%" height="91" bgcolor="#0099FF">&nbsp;
    <img alt ="[Company Logo]"
    src="puj2.gif" width="100" height="100">
    <p>
    </td>
    <td width="78%" height="91" bgcolor="#66CCFF" ALIGN=CENTER>&nbsp;

<H1> Search </H1>


    </td>
  </tr>
  <tr>
    <td width="22%" height="123" bgcolor="#6699FF">&nbsp;
      <div class="buttonscontainer">
      <div class="buttons">
      <a href="gen_homepage.php">Homepage</a>
      <a href="register.php">Register</a>
      <a href="calendar.php">Calendar</a>
      <a href="weatherinfo.php">Weather Information</a>
      <a href="travelinfo.php">Travel Information</a>
      <a href="logout.php">Logout</a>
      </div>
      </div>
    </td>
    <td width="78%" height="123" bgcolor="#99CCFF" ALIGN=CENTER>
     &nbsp;
          &nbsp;
          &nbsp;
          <?
      $accommID = $_POST ["accommID"];
       ?>
 <center>
    <form name="search2.php" action="search_results2.php" method="POST">
          <font face="arial" size ="1">
    Type:
    <select name="select_type">
            <option value='Villa'>Villa</option>
            <option value='Caravan'>Caravan</option>
            <option value='Lodge'>Lodge</option>
          </select>
          &nbsp;
          Sleeps:
          <select name="select_sleeps">
            <option value='2'>Up to 2</option>
            <option value='4'>Up to 4</option>
            <option value='6'>Up to 6</option>
            <option value='8'>Up to 8</option>
            <option value='10'>Up to 10</option>
          </select> &nbsp; <br> <br>
          Board:
          <select name="select_board">
            <option value='Full Board'>Full Board</option>
            <option value='Half Board'>Half Board</option>
            <option value='B & B'>B & B</option>
            <option value='Self-Catering'>Self-Catering</option>
          </select> &nbsp;
          Pets Allowed:
          <select name="select_pets_allowed">
            <option value='Yes'>Yes</option>
            <option value='No'>No</option>
          </select> &nbsp;
          <br> <br>
          <input type="hidden" name="accommID" value="' . $accommID . '" />
           <center> <input type="submit" value="Search"></center>






  </form>
</td>



</table>
<?
}
?>

</body>
</html>



search_results2.php


<html>
<head>
<title><?php echo "Search Results" ?></title>
<link rel="stylesheet" type="text/css" href="template2.css">
<head>
<body>

<?
session_start();
if(!isset($_SESSION[user_name])) { echo "<p><center>Please login to view this page.</p><p>&nbsp;</p> Please wait... You will automatically be redirected back to the login page";
echo "<META HTTP-EQUIV=Refresh CONTENT='3; URL=gen_homepage.php'>";


} else {

require_once("config.php");
     $connection = @mysql_connect($db_host, $db_user, $db_password) or die("oops! error connecting");
     
     mysql_select_db($db_name, $connection);



?>                                                

<table border="1" width="100%" height="226">
  <tr>
    <td width="22%" height="91" bgcolor="#0099FF">&nbsp;
    <img alt ="[Company Logo]"
    src="puj2.gif" width="100" height="100">
    <p>
    </td>
    <td width="78%" height="91" bgcolor="#66CCFF" ALIGN=CENTER>&nbsp;

<H1> Search Results</H1>

    </td>
  </tr>
  <tr>
    <td width="22%" height="123" bgcolor="#6699FF">&nbsp;
      <div class="buttonscontainer">
      <div class="buttons">
      <a href="search2.php">Search Again</a>
      <a href="logout.php">Logout</a>
      </div>
      </div>
    </td>
    <td width="78%" height="123" bgcolor="#99CCFF" ALIGN=CENTER>
    
    <?
    
    
$self = $_SERVER['PHP_SELF'];
$accommID = $_POST ["accommID"];
$type = $_POST["select_type"];
$sleeps = $_POST["select_sleeps"];
$board = $_POST["select_board"];
$description = $_POST["description"];
$pets_allowed = $_POST["select_pets_allowed"];


//$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type = '$type' AND sleeps = '$sleeps' AND board = '$board' AND description= '$description' AND pets_allowed = '$pets_allowed'";
$query = "SELECT accommID, type, sleeps, board, description, pets_allowed FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed'";
$result = mysql_query ($query) or die(mysql_error());

$num = mysql_num_rows($result);

if ($num > 0){

             echo "<p>There is currently $num accommodation(s). </p>\n";
              echo '<FORM METHOD="POST" ACTION="add_book.php">';
              echo '<table align = "center" border = "1" cellspacing = "0" cellpadding = "5">
              <tr>
              <td align="left"><b>Type</b></td>
              <td align="left"><b>Sleeps</b></td>
              <td align="left"><b>Board</b></td>
              <td align="left"><b>Description</b></td>
              <td align="left"><b>Pets Allowed</b></td>

              </tr>
              ';
              
              while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
                echo '
              <tr>
              <td align="left">'. $row['type']. '</td>
              <td align="left">'. $row['sleeps']. '</td>
              <td align="left">'. $row['board']. '</td>
              <td align="left">'. $row['description']. '</td>
              <td align="left">'. $row['pets_allowed']. '</td>
              <td align=center><input type=radio name=accommID value="'.$row['accommID'].'"></td>
              </tr>
              ';
              }

              echo '</table>';
              echo '&nbsp';
              echo '<center> <input type="submit" value="Continue Booking"></center>';
              
              mysql_free_result($result);
              

              } else {

                  echo '<p class = "error">There are currently no types of accommodation for the choices entered.</p>';
              }


              echo '</FORM>';

              mysql_close();

              //$statment =mysql_query ("SELECT type FROM accommodation WHERE type = '$type' and sleeps ='$sleeps' and board ='$board' and pets_allowed = '$pets_allowed'");// WHERE type = '$type' AND sleeps = '$sleeps' AND board = '$board' AND pets_allowed = '$pets_allowed'");
              //print $statment;
              //$query = mysql_query($statment) or die(mysql_error());

?>


  </form>
</td>



</table>
<?
}
?>

</body>




and finally the last one is add_book.php


<?php

session_start();
if(!isset($_SESSION[user_name])) { echo "<p><center>Please login to view this page.</p><p>&nbsp;</p> Please wait... You will automatically be redirected back to the login page";
echo "<META HTTP-EQUIV=Refresh CONTENT='3; URL=gen_homepage.php'>";
} else {

require_once("config.php");
     $connection = @mysql_connect($db_host, $db_user, $db_password) or die("oops! error connecting");

      mysql_select_db($db_name, $connection);

         $self = $_SERVER['PHP_SELF'];

         //$book_start = $_POST ["booking_start_date"];

         //$len = strlen($book_start);
         //if ($len > 0)
         //{
         $accommID = $_POST ["accommID"];
         $book_start = $_POST ["booking_start_date"];
         $book_end = $_POST ["booking_end_date"];
         $query = "INSERT INTO booking (booking_start_date, booking_end_date, accommID) VALUES ('$book_start','$book_end','$accommID')";

         mysql_query($query, $connection) or die (mysql_error());

         //}


?>
<html>
<head>
<title><?php echo "Add Booking" ?></title>
<link rel="stylesheet" type="text/css" href="template2.css">
<head>
<body>

<table border="1" width="100%" height="226">
  <tr>
    <td width="22%" height="91" bgcolor="#0099FF">&nbsp;
    <img alt ="[Company Logo]"
    src="puj2.gif" width="100" height="100">
    <p>
    </td>
    <td width="78%" height="91" bgcolor="#66CCFF" ALIGN=CENTER>&nbsp;

<H1> Add Booking </H1>

    </td>
  </tr>
  <tr>
    <td width="22%" height="123" bgcolor="#6699FF">&nbsp;
     <div class="buttonscontainer">
      <div class="buttons">
    <a href="cust_homepage.php">Customer Homepage</a>
    <a href="calendar.php">Calendar</a>
    <a href="logout.php">Logout</a>
    </div>
    </div>
    </td>
    <td width="78%" height="123" bgcolor="#99CCFF" ALIGN=CENTER>
    
     <p>&nbsp;</p>
    <form action ="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">
    <p align="center">&nbsp;</p>
    <p align="center"><u>Booking Start Date (YYYY/MM/DD):</u>&nbsp;&nbsp;&nbsp; <input type="text" name="booking_start_date" size="20"></p>
    <p align="center"><u>Booking End Date (YYYY/MM/DD) :</u>&nbsp;&nbsp;&nbsp; <input type="text" name="booking_end_date" size="20"></p>
    <p>&nbsp;</p>
    <p><input type="submit" value="Submit"></p>
  </form>

  
  
  </form>
</td>



</table>
<?
} 
?>
</body>

</html>


thank u for ur help!

puja

#9 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 04 May 2006 - 04:08 PM

OK I adjusted a few things on each page. So name the pages accordingly and check to make sure the action part of the forms goes to the correct pages.

search.php
<?
session_start();
if(!isset($_SESSION['user_name'])) {
    echo "<p><center>Please login to view this page.</p><p> </p> Please wait... You will automatically be redirected back to the login page";
    echo "<META HTTP-EQUIV=Refresh CONTENT='3; URL=gen_homepage.php'>";
} else {
?>
<html>
<head>
<title>Search</title>
<link rel="stylesheet" type="text/css" href="template2.css">
<head>
<body>
<?
// No need for database connection because you are only filling in a form right now
//   $connection = @mysql_connect($db_host, $db_user, $db_password) or die("oops! error connecting");
//  mysql_select_db($db_name, $connection);
?>

<table border="1" width="100%" height="226">
  <tr>
    <td width="22%" height="91" bgcolor="#0099FF"> 
    <img alt ="[Company Logo]"
    src="puj2.gif" width="100" height="100">
    <p>
    </td>
    <td width="78%" height="91" bgcolor="#66CCFF" ALIGN=CENTER> 

<H1> Search </H1>


    </td>
  </tr>
  <tr>
    <td width="22%" height="123" bgcolor="#6699FF"> 
      <div class="buttonscontainer">
      <div class="buttons">
      <a href="gen_homepage.php">Homepage</a>
      <a href="register.php">Register</a>
      <a href="calendar.php">Calendar</a>
      <a href="weatherinfo.php">Weather Information</a>
      <a href="travelinfo.php">Travel Information</a>
      <a href="logout.php">Logout</a>
      </div>
      </div>
    </td>
    <td width="78%" height="123" bgcolor="#99CCFF" ALIGN=CENTER>
      
           
           
          <?
// No need for this now you have now found the accomodation
// $accommID = $_POST ["accommID"];
       ?>
<center>
    <form name="booksearch" action="searchresults.php" method="POST">
          <font face="arial" size ="1">
    Type:
    <select name="select_type">
            <option value='Villa'>Villa</option>
            <option value='Caravan'>Caravan</option>
            <option value='Lodge'>Lodge</option>
          </select>
           
          Sleeps:
          <select name="select_sleeps">
            <option value='2'>Up to 2</option>
            <option value='4'>Up to 4</option>
            <option value='6'>Up to 6</option>
            <option value='8'>Up to 8</option>
            <option value='10'>Up to 10</option>
          </select>   <br> <br>
          Board:
          <select name="select_board">
            <option value='Full Board'>Full Board</option>
            <option value='Half Board'>Half Board</option>
            <option value='B & B'>B & B</option>
            <option value='Self-Catering'>Self-Catering</option>
          </select>  
          Pets Allowed:
          <select name="select_pets_allowed">
            <option value='Yes'>Yes</option>
            <option value='No'>No</option>
          </select>  
          <br> <br>
           <center> <input type="submit" value="Search"></center>
  </form>
</td>
</table>
<?
}
?>
</body>
</html>

searchresults.php
<?
session_start();
if(!isset($_SESSION['user_name'])) { echo "<p><center>Please login to view this page.</p><p> </p> Please wait... You will automatically be redirected back to the login page";
echo "<META HTTP-EQUIV=Refresh CONTENT='3; URL=gen_homepage.php'>";
} else {
echo "<html>
      <head>
      <title>Search Results</title>
      <link rel=\"stylesheet\" type=\"text/css\" href=\"template2.css\">
      <head>
      <body>";

$connection = @mysql_connect($db_host, $db_user, $db_password) or die("oops! error connecting");
mysql_select_db($db_name, $connection);
?>

<table border="1" width="100%" height="226">
  <tr>
    <td width="22%" height="91" bgcolor="#0099FF"> 
    <img alt ="[Company Logo]"
    src="puj2.gif" width="100" height="100">
    <p>
    </td>
    <td width="78%" height="91" bgcolor="#66CCFF" ALIGN=CENTER> 

<H1> Search Results</H1>

    </td>
  </tr>
  <tr>
    <td width="22%" height="123" bgcolor="#6699FF"> 
      <div class="buttonscontainer">
      <div class="buttons">
      <a href="search2.php">Search Again</a>
      <a href="logout.php">Logout</a>
      </div>
      </div>
    </td>
    <td width="78%" height="123" bgcolor="#99CCFF" ALIGN=CENTER>

    <?


$self = $_SERVER['PHP_SELF'];
$type = $_POST["select_type"];
$sleeps = $_POST["select_sleeps"];
$board = $_POST["select_board"];
$pets_allowed = $_POST["select_pets_allowed"];


//$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type = '$type' AND sleeps = '$sleeps' AND board = '$board' AND description= '$description' AND pets_allowed = '$pets_allowed'";
$query = "SELECT accommID, type, sleeps, board, description, pets_allowed FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed'";
$result = mysql_query ($query) or die(mysql_error());

$num = mysql_num_rows($result);

if ($num > 0){

             echo "<p>There is currently $num accommodation(s). </p>\n";
              echo '<FORM METHOD="POST" ACTION="add_book.php">';
              echo '<table align = "center" border = "1" cellspacing = "0" cellpadding = "5">
              <tr>
              <td align="left"><b>Type</b></td>
              <td align="left"><b>Sleeps</b></td>
              <td align="left"><b>Board</b></td>
              <td align="left"><b>Description</b></td>
              <td align="left"><b>Pets Allowed</b></td>

              </tr>
              ';

              while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
                echo '
              <tr>
              <td align="left">'. $row['type']. '</td>
              <td align="left">'. $row['sleeps']. '</td>
              <td align="left">'. $row['board']. '</td>
              <td align="left">'. $row['description']. '</td>
              <td align="left">'. $row['pets_allowed']. '</td>
              <td align=center><input type=radio name=accommID value="'.$row['accommID'].'"></td>
              </tr>
              ';
              }

              echo '</table>';
              echo ' ';
              echo '<center> <input type="submit" value="Continue Booking"></center>';
              echo '</FORM>';
              mysql_free_result($result);


              } else {

                  echo '<p class = "error">There are currently no types of accommodation for the choices entered.</p>';
              }
              mysql_close();

              //$statment =mysql_query ("SELECT type FROM accommodation WHERE type = '$type' and sleeps ='$sleeps' and board ='$board' and pets_allowed = '$pets_allowed'");// WHERE type = '$type' AND sleeps = '$sleeps' AND board = '$board' AND pets_allowed = '$pets_allowed'");
              //print $statment;
              //$query = mysql_query($statment) or die(mysql_error());

?>
</td>
</table>
<?
}
?>
</body>
</html>

add_book.php
<?php
session_start();
if(!isset($_SESSION['user_name'])) { echo "<p><center>Please login to view this page.</p><p> </p> Please wait... You will automatically be redirected back to the login page";
echo "<META HTTP-EQUIV=Refresh CONTENT='3; URL=gen_homepage.php'>";
} else {
?>
<html>
<head>
<title>Add Booking</title>
<link rel="stylesheet" type="text/css" href="template2.css">
<head>
<body>

<table border="1" width="100%" height="226">
  <tr>
    <td width="22%" height="91" bgcolor="#0099FF"> 
    <img alt ="[Company Logo]"
    src="puj2.gif" width="100" height="100">
    <p>
    </td>
    <td width="78%" height="91" bgcolor="#66CCFF" ALIGN=CENTER> 

<H1> Add Booking </H1>

    </td>
  </tr>
  <tr>
    <td width="22%" height="123" bgcolor="#6699FF"> 
     <div class="buttonscontainer">
      <div class="buttons">
    <a href="cust_homepage.php">Customer Homepage</a>
    <a href="calendar.php">Calendar</a>
    <a href="logout.php">Logout</a>
    </div>
    </div>
    </td>
    <td width="78%" height="123" bgcolor="#99CCFF" ALIGN=CENTER>

     <p> </p>
<?
if(isset($_POST['submit'])){
$connection = @mysql_connect($db_host, $db_user, $db_password) or die("oops! error connecting");
mysql_select_db($db_name, $connection);

         //$book_start = $_POST ["booking_start_date"];

         //$len = strlen($book_start);
         //if ($len > 0)
         $accommID = $_POST ["accommID"];
         $book_start = $_POST ["booking_start_date"];
         $book_end = $_POST ["booking_end_date"];
         $query = "INSERT INTO booking (booking_start_date, booking_end_date, accommID) VALUES ('$book_start','$book_end','$accommID')";
           $result = mysql_query($query) or die (mysql_error());
             if(!$result){
             echo "Booking not added
             </td>
            </table>";
             } else {
             echo "You have succeffully booked...
             </td>
            </table>";
             }
} else {
$accommid = $_POST['accommID'];
?>
    <form action ="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
    <input type=hidden name=accommID value="<?=$accommid?>">
    <p align="center"> </p>
    <p align="center"><u>Booking Start Date (YYYY/MM/DD):</u>    <input type="text" name="booking_start_date" size="20"></p>
    <p align="center"><u>Booking End Date (YYYY/MM/DD) :</u>    <input type="text" name="booking_end_date" size="20"></p>
    <p> </p>
    <p><input type="submit" name=submit value="Submit"></p>
  </form>
</td>
</table>
<?
}
echo "</body>
      </html>";
}
?>

Might want to go through the code and clean things up, people with different browsers will get different looks if the code in not "clean". By clean I mean make sure all your tags are closed and in the right place.

Let me know how you make out

Ray






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users