Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show and Hide form from user

Status
Not open for further replies.

hb25

Programmer
Mar 1, 2009
21
0
0
GB
Hi
I explain what I have, user will visi the site to change booking detail using their client and booking ID, once thy typed their client ID they will be directed to another page where they will be welcomed and they will be presented with a form to enter the booking ID they need to change and their new booking detils.

My question is what is the if statement which only show the second part (Form) to the user only if they have typed corecet client ID. i.e if their is no recored of then they shoud get an error message saying that we don’t have a recored for you please try again.

Hope i have manged to explain my question well. Below is the code which i am using in my page.
Code:
<html>
<head>
<title>change Booking  Details</title>
</head>
<body>
<?php
// Have they entered a ClientID?
if(empty($_POST['clientID']))
{
	die("Please enter your correct BookingID number.");
}

$con = mysql_connect("xxxxxxxx","xxxxxx","xxxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("xxxxxxxx", $con);



$result = mysql_query("SELECT * FROM clients WHERE clientID=$_POST[clientID]");

 
// if statment should start here


// if statment should finish here 

while($row = mysql_fetch_array($result))
  {
  print "Hi";
  echo(" ");
  echo $row['firstname'] . " " . $row['surname'];
  echo(" ");
  echo("welcome back you can change your booking using the form below  ");
  echo "<br />";
  }



mysql_close($con)
?>
<p> hi </p>
<form name="form1" method="post" action="../actions/booking_updated.php">
  <table width="75%" border="1">
    <tr>
      <td>Bookin ID</td>
      <td><input type="text" name="bookingID"></td>
    </tr>
    <tr> 
      <td width="34%">Arrival Date</td>
      <td width="66%"> <input name="startdate" type="text" id="startdate" maxlength="10">
        (yyyy-mm-dd) </td>
    </tr>
    <tr> 
      <td>Departure Date</td>
      <td><input name="enddate" type="text" id="enddate" maxlength="10">
        (yyyy-mm-dd) </td>
    </tr>
    <tr> 
      <td>Room Type</td>
      <td><select name="roomtype" id="roomtype">
          <option value="Single">Single</option>
          <option value="Double">Double</option>
          <option value="Suite" selected>Suite</option>
        </select></td>
    </tr>
    <tr> 
      <td>Number of Adults:</td>
      <td><select name="adults" id="adults">
          <option value="1">1</option>
          <option value="2">2</option>
        </select></td>
    </tr>
    <tr> 
      <td>Number of Children:</td>
      <td><select name="children" id="children">
          <option value="0">0</option>
          <option value="1">1</option>
          <option value="2">2</option>
        </select></td>
    </tr>
    <tr> 
      <td>Special Requirments</td>
      <td><textarea name="requirements" cols="30" id="requirements"></textarea></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td><input name="updatebooking" type="submit" id="updatebooking" value="Update Booking"></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
<p>&nbsp;</p>
</body>
</html>

 
You've already ran the query, you just need to check the results for the client id query to make sure something was returned:.

Code:
$result = mysql_query("SELECT * FROM clients WHERE clientID=$_POST[clientID]");

 
// if statment should start here
[red]
if(mysql_num_rows($result)<>1){
echo "Error: invalid Client Id";
exit;
}
[/red]
// if statment should finish here 

while($row = mysql_fetch_array($result))
  {


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top