kerell78us Posted December 12, 2007 Share Posted December 12, 2007 I am actually doing a school project that is due at the end of the week. I have on my home page the following form: <form action="availability.php" method="post" enctype="multipart/form-data" name="availability" id="availability"> <table width="100%" border="0" cellpadding="1" align="left"> <tr> <td width="21%"><span class="style2">Arrival:</span></td> <td width="79%"><input name="reserve_checkin_date" type="text" id="reserve_checkin_date" value="<?php $_POST['reserve_checkin_date']; ?>" /> <a href="javascript:showCal('Calendar3')"> <img src="images/ew_calendar.gif" width="16" height="15" border="0"/> <input name="hiddenField" type="hidden" id="hiddenField" value="reserve_checkin_date" /> </a></td> </tr> <tr> <td><span class="style2">Departure:</span> </td> <td><input name="reserve_checkout_date" type="text" id="reserve_checkout_date" onblur="nights()" value="<?php $_POST['reserve_checkout_date']; ?>"/> <small><a href="javascript:showCal('Calendar4')"> <img src="images/ew_calendar.gif" width="16" height="15" border="0"/> <input name="hiddenField" type="hidden" id="hiddenField" value="reserve_checkout_date" /> </a></small></td> </tr> <tr> <td colspan="2"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Check Availability"/> <input name="action" type="hidden" id="action" value="availability" /></td> </tr> </table> </form> the above form is posted to: <?php // Retrieve the hidden form variable. // $reserve_checkin_date = $_POST['reserve_checkin_date']; // $reserve_checkout_date = $_POST['reserve_checkout_date']; if(isset($action) && $action =="availability") { $reserve_checkin_date=!empty($_POST["reserve_checkin_date"]) ? "'" . $_POST["reserve_checkin_date"] . "'" : 'NULL'; $reserve_checkout_date=!empty($_POST["reserve_checkout_date"]) ? "'" . $_POST["reserve_checkout_date"] . "'" : 'NULL'; } $link = mysql_connect(localhost, root, anyone) or die("I'm sorry this is not available now. "); if (!mysql_select_db("hotels", $link)) { echo "I'm sorry this is not available now. "; exit; } $sql = "SELECT rooms.room_no, rooms.room_type_id, rooms.room_name, rooms.rate, reservation.reserve_checkin_date, reservation.reserve_checkout_date FROM ROOMS, RESERVATION WHERE rooms.status = 'V' AND reservation.reserve_checkin_date>=' " . $_POST[reserve_checkin_date] . "' AND reservation.reserve_checkout_date >=' " . $_POST[reserve_checkout_date] ."' GROUP BY rooms.room_type_id, rooms.room_name, rooms.rate ORDER BY rooms.rate, rooms.room_id asc "; if ( @mysql_query ( $sql, $link ) ) { $query = mysql_query ( $sql ); $row = mysql_fetch_assoc ( $query ); do { echo " <table width=100\'%' border=0 cellspacing=0 cellpadding=1> <tr> <td>" . $row["room_name"] . "</td> <td align=right><table width=100\'%' border=0 align=right cellpadding=0 cellspacing=0> <tr> <td align=right>" . $row["rate"] . "</td> </tr> </table></td> </tr> <tr> <td colspan=2></td> </tr> <tr> <td colspan=2 align=right><a href='reserve.php?room_id=" . $row['room_id'] . "'&$reserve_checkin_date=" . $_POST['reserve_checkin_date'] . "&$reserve_checkout_date=" . $_POST['reserve_checkout_date'] . $row['rate'] . "><img src=images/reserve.png width=60 height=17></a></td> </tr> </table><br>"; } while ( $row = mysql_fetch_assoc ( $query ) ); } else { die ( mysql_error () ); } ?> How do I post the values entered in my "availability" form to my availability.php script. Then record the action of the user which would be triggered by the use of the "reserve" button. Basically, from the page that displays the available rooms, I would like for the to be able to reserve the room of his/her choice and calculate the room cost for the requested period as per value entered in the availability form. The cost would then be posted to the two-step confirmation.php page which would update the guest and reservation tables (below is the script I wrote to update the two tables) in step-one then, send the reservation cost to the payment page. I hope I haven't confused you guys; I am really desperate for your assistance... Script to update guests and reservation tables: $guest_id=$_POST["guest_id"]; $reservation_by=!empty($_POST["reservation_by"]) ? "'" . $_POST["reservation_by"] . "'" : 'NULL'; $reserve_checkin_date=!empty($_POST["reserve_checkin_date"]) ? "'" . $_POST["reserve_checkin_date"] . "'" : 'NULL'; $reserve_checkout_date=!empty($_POST["reserve_checkout_date"]) ? "'" . $_POST["reserve_checkout_date"] . "'" : 'NULL'; $no_nights=!empty($_POST["no_nights"]) ? $_POST["no_nights"] : 'NULL'; $room_no=!empty($_POST["room_no"]) ? $_POST["room_no"] : 'NULL'; $room_id=!empty($_POST["room_id"]) ? $_POST["room_id"] : 'NULL'; $first_name=$_POST["first_name"]; $last_name=$_POST["last_name"]; $countrycode= $_POST["countrycode"]; $guest_pp_no=($_POST["identification_no"]==guest_pp_no) ? "'" . $_POST["pp_id_no"] . "'" : 'NULL'; $guest_identi_no=($_POST["identification_no"]==guest_identi_no) ? "'" . $_POST["pp_id_no"] . "'" : 'NULL'; $pobox=$_POST["pobox"]; $town=$_POST["town"]; $postal_code=$_POST["postal_code"]; $guest_phone=$_POST["guest_phone"]; $guest_email=$_POST["guest_email"]; $guest_mobile=$_POST["guest_mobile"]; $sql="INSERT INTO guests (last_name, first_name, guest_pp_no, guest_identi_no, countrycode, pobox, town, postal_code, guest_phone, guest_email, guest_mobile) VALUES('$last_name', '$first_name', $guest_pp_no, $guest_identi_no, '$countrycode', '$pobox', '$town', '$postal_code', '$guest_phone', '$guest_email', '$guest_mobile')"; if( isset($guest_id, $reservation_by, $reserve_checkin_date, $reserve_checkout_date, $no_nights, $room_no, $room_id)) { // get the guest_id $guest_id = mysql_insert_id( $conn ); // Inserting the data into users // ----------------------------- $sql = "INSERT INTO reservation VALUES (NULL, '$guest_id', '$reservation_by', '$reserve_checkin_date', '$reserve_checkout_date', '$no_nights', '$room_no', '$room_id') SET rooms.status='R'"; $result = mysql_query( $sql,$conn ); //mark room as booked $sql="Update rooms set status='R' where room_id=$room_id"; $results=mkr_query($sql,$conn); $msg[0]="Sorry room reservation not marked"; $msg[1]="Your room marked as reserved"; AddSuccess($results,$conn,$msg); } } } mysql_free_result( $result ); // ---------------------------- ?> Quote Link to comment Share on other sites More sharing options...
slapdashgrim Posted December 12, 2007 Share Posted December 12, 2007 what is your problem or what do you need help with. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.