Wrox Programmer Forums
|
BOOK: Dreamweaver MX: PHP Web Development
This is the forum to discuss the Wrox book Dreamweaver MX: PHP Web Development by Gareth Downes-Powell, Tim Green, Bruno Mairlot; ISBN: 9780764543876
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Dreamweaver MX: PHP Web Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2005, 10:57 AM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query

Hello,

I am getting the information which I have inserted into "booking_details.php" from "confirm_booking.php" but at the end of "confirm_booking.php" page when I click on button "change detais" it should go back to 'change_booking_details.php" with the information what I had entered. For example if I have entered record for Mr.Mike and got bookingID 35 and now I enter for Mr. Sam and get bookingID 36. On Mr.Sam's booking when I change detail it goes to Mr. Mike's rcord and update occurs in Mr. Mike's record. Even If I go to "Change_booking.php" and enter same booking ID,which I get from "confirm_booking.php" page it shows all previous information instead that particular bookingID information. Problem seems to be linking between "confirm_booking.php" to "change_booking_details.php"
I have corrected page 155 with " .$HTTP_POST_VARS['bookingID']." Even $_POST_VARS does not show any changes.[/b][/b]

Here is my code:

<?php require_once('../../Connections/conndwhotel.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
    case "text":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
    case "long":
    case "int":
     $theValue = ($theValue != "") ? intval($theValue) : "NULL";
     break;
    case "double":
     $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
     break;
    case "date":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
    case "defined":
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
     break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "bookroom")) {
$updateSQL = sprintf("UPDATE bookings SET clientID=%s, startDate=%s, endDate=%s, adults=%s, children=%s, roomType=%s, roomOptions=%s, networkConnections=%s, PC=%s, requirements=%s WHERE ID=%s",
                     GetSQLValueString($_POST['clientID'], "int"),
                     GetSQLValueString($_POST['arrivalDate'], "date"),
                     GetSQLValueString($_POST['enddate'], "date"),
                     GetSQLValueString($_POST['adults'], "text"),
                     GetSQLValueString($_POST['children'], "int"),
                     GetSQLValueString($_POST['roomType'], "text"),
                     GetSQLValueString($_POST['roomoptions'], "int"),
                     GetSQLValueString(isset($_POST['networkconnections']) ? "true" : "", "defined","1","0"),
                     GetSQLValueString(isset($_POST['pc']) ? "true" : "", "defined","1","0"),
                     GetSQLValueString($_POST['requirements'], "text"),
                     GetSQLValueString($_POST['bookingID'], "int"));

mysql_select_db($database_conndwhotel, $conndwhotel);
$Result1 = mysql_query($updateSQL, $conndwhotel) or die(mysql_error());

$updateGoTo = "booking_updated.php?ID=" . $HTTP_POST_VARS['bookingID'] ."&clientID=" . $HTTP_POST_VARS['clientID'] ."";
if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}

$colname_rsBooking = "1";
if (isset($_POST['ID'])) {
$colname_rsBooking = (get_magic_quotes_gpc()) ? $_POST['ID'] : addslashes($_POST['ID']);
}
mysql_select_db($database_conndwhotel, $conndwhotel);
$query_rsBooking = sprintf("SELECT * FROM bookings WHERE ID = %s", $colname_rsBooking);
$rsBooking = mysql_query($query_rsBooking, $conndwhotel) or die(mysql_error());
$row_rsBooking = mysql_fetch_assoc($rsBooking);
$totalRows_rsBooking = mysql_num_rows($rsBooking);

$varBookingID_rsClient = "0";
if (isset($row_rsBooking['clientID'])) {
$varBookingID_rsClient = (get_magic_quotes_gpc()) ? $row_rsBooking['clientID'] : addslashes($row_rsBooking['clientID']);
}
mysql_select_db($database_conndwhotel, $conndwhotel);
$query_rsClient = sprintf("SELECT * FROM client WHERE ID = %s", $varBookingID_rsClient);
$rsClient = mysql_query($query_rsClient, $conndwhotel) or die(mysql_error());
$row_rsClient = mysql_fetch_assoc($rsClient);
$totalRows_rsClient = mysql_num_rows($rsClient);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>sisoti-inn hotel</title>
<style type="text/css">
<!--
body {
    background-color: #996666;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
body,td,th {
    color: #000000;
}
.style1 {
    font-size: xx-large;
    color: #FFFFFF;
}
.style2 {font-size: xx-large}
-->
</style>

</head>

<body>
<table width="640" height="723" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
    <td height="723" align="left" valign="top" bordercolor="#000000" bgcolor="#666666"><table width="640" height="100" border="0" cellpadding="0" cellspacing="0">
     <tr>
        <td background="../images/leaves.jpg"><strong><span class="style1">HOTEL SISOTI-INN </span></strong></td>
     </tr>
    </table>
     <table width="640" border="0" cellspacing="0" cellpadding="0">
        <tr bordercolor="#0000FF">
         <td bgcolor="#FFFFFF"><div align="center"><strong><a href="../index.php" target="_parent">HOME</a></strong></div></td>
         <td bgcolor="#CCCCCC"><div align="center"><strong><a href="book_a_room.php" target="_parent">BOOK A ROOM </a></strong></div></td>
         <td bgcolor="#FFFFFF"><div align="center"><strong><a href="change_booking.php" target="_parent">CHANGE BOOKING</a> </strong></div></td>
         <td bgcolor="#CCCCCC"><div align="center"><strong><a href="cancel_booking.php" target="_parent">CANCEL BOOKING </a></strong></div></td>
         <td bgcolor="#FFFFFF"><div align="center"><strong>ABOUT US </strong></div></td>
        </tr>
     </table>
    <p align="center"><span class="style2">Change Booking Details</span><br>
     <strong>Thank you,<?php echo $row_rsClient['firstname']; ?> <?php echo $row_rsClient['lastname']; ?>, you can change your booking details below </strong></p>
    <form action="<?php echo $editFormAction; ?>" method="POST" name="bookroom" target="_parent" id="bookroom">
     <table width="567" border="2" align="center" cellpadding="2" cellspacing="0">
        <tr>
         <td width="191" height="31"><div align="right"><strong>Arrival Date:</strong></div></td>
         <td width="271"><input name="arrivalDate" type="text" id="arrivalDate" value="<?php echo $row_rsBooking['startDate']; ?>" size="10" maxlength="10">
     (yyyy-mm-dd)</td>
        </tr>
        <tr>
         <td><div align="right"><strong>Departure Date: </strong></div></td>
         <td><input name="enddate" type="text" id="enddate" value="<?php echo $row_rsBooking['endDate']; ?>" size="10" maxlength="10">
     (yyyy-mm-dd)</td>
        </tr>
        <tr>
         <td><div align="right"><strong>Room Type: </strong></div></td>
         <td><select name="roomType" size="1" id="roomType">
            <option value="Single" <?php if (!(strcmp("Single", $row_rsBooking['roomType']))) {echo "SELECTED";} ?>>Single</option>
            <option value="Double" <?php if (!(strcmp("Double", $row_rsBooking['roomType']))) {echo "SELECTED";} ?>>Double</option>
            <option value="Suite" <?php if (!(strcmp("Suite", $row_rsBooking['roomType']))) {echo "SELECTED";} ?>>Suite</option>
         </select></td>
        </tr>
        <tr>
         <td><div align="right"><strong>In Room Extras Required: </strong></div></td>
         <td><input <?php if (!(strcmp($row_rsBooking['networkConnections'],1))) {echo "checked";} ?> name="networkconnections" type="checkbox" id="networkconnections" value="1">
     Network Connection </td>
        </tr>
        <tr>
         <td><div align="right"></div></td>
         <td><input <?php if (!(strcmp($row_rsBooking['PC'],1))) {echo "checked";} ?> name="pc" type="checkbox" id="pc" value="1">
     Personal Computer </td>
        </tr>
        <tr>
         <td><div align="right"><strong>Number of Adults: </strong></div></td>
         <td><select name="adults" id="adults">
            <option value="1" <?php if (!(strcmp(1, $row_rsBooking['adults']))) {echo "SELECTED";} ?>>1</option>
            <option value="2" <?php if (!(strcmp(2, $row_rsBooking['adults']))) {echo "SELECTED";} ?>>2</option>
            <option value="3" <?php if (!(strcmp(3, $row_rsBooking['adults']))) {echo "SELECTED";} ?>>3</option>
         <option value="4" <?php if (!(strcmp(4, $row_rsBooking['adults']))) {echo "SELECTED";} ?>>4</option>
         </select></td>
        </tr>
        <tr>
         <td><div align="right"><strong>Number of Children: </strong></div></td>
         <td><select name="children" id="children">
            <option value="0" <?php if (!(strcmp(0, $row_rsBooking['children']))) {echo "SELECTED";} ?>>0</option>
            <option value="1" <?php if (!(strcmp(1, $row_rsBooking['children']))) {echo "SELECTED";} ?>>1</option>
            <option value="2" <?php if (!(strcmp(2, $row_rsBooking['children']))) {echo "SELECTED";} ?>>2</option>
            <option value="3" <?php if (!(strcmp(3, $row_rsBooking['children']))) {echo "SELECTED";} ?>>3</option>
            <option value="4" <?php if (!(strcmp(4, $row_rsBooking['children']))) {echo "SELECTED";} ?>>4</option>
         </select></td>
        </tr>
        <tr>
         <td><div align="right"><strong>Room Options: </strong></div></td>
         <td><p>
             <label>
             <input <?php if (!(strcmp($row_rsBooking['roomOptions'],"0"))) {echo "CHECKED";} ?> type="radio" name="roomoptions" value="0">
        Smoking</label>
             <input <?php if (!(strcmp($row_rsBooking['roomOptions'],"1"))) {echo "CHECKED";} ?> type="radio" name="roomoptions" value="1">
             <label>Non Smoking</label>
             <br>
         </p></td>
        </tr>
        <tr>
         <td><div align="right"><strong>Special Requirements: </strong></div></td>
         <td><div align="left">
             <textarea name="requirements" cols="30" rows="6" id="requirements"><?php echo $row_rsBooking['requirements']; ?></textarea>
         </div></td>
        </tr>
        <tr>
         <td><div align="right">
             <input name="bookingID" type="hidden" id="bookingID" value="<?php echo $row_rsBooking['ID']; ?>">
             <input name="clientID" type="hidden" id="clientID" value="<?php echo $row_rsBooking['clientID']; ?>">
         </div></td>
         <td>&nbsp;</td>
        </tr>
        <tr>
         <td>&nbsp;</td>
         <td><div align="center">
             <input name="bookaroom" type="submit" id="bookaroom" value="Book a Room">
         </div></td>
        </tr>
     </table>
        <input type="hidden" name="MM_update" value="bookroom">
    </form> <p align="center">&nbsp;</p>
    <p align="center">&copy; Sisoti-Inn Private Co. Ltd, All rights reserved: <a href="mailto:[email protected]" target="_blank">Email</a></p></td>
</tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($rsBooking);

mysql_free_result($rsClient);
?>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.