Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------Home Page--------------
- <!DOCTYPE html>
- <html>
- <head>
- <title>My Hotel</title>
- <style>
- body {
- background-color: green;
- text-align: center;
- color: white;
- font-family: Arial, Helvetica, sans-serif;
- }
- </style>
- </head>
- <body>
- <h1>My Hotel</h1>
- <p>This is the address of My Hotel.</p>
- <p>other details like e-mail, ph. no. etc</p>
- <img src="hotel.png" alt="MyHotel" style="width:200px">
- <form action="myHotel.php" method="post">
- Name: <input type="text" name="name"><br>
- E-mail: <input type="text" name="email"><br>
- No Of Rooms: <input list="count" type="text" name="rooms"><br>
- No Of Adults: <input list="count" type="text" name="adults"><br>
- No Of Children: <input list="count" type="text" name="children"><br>
- Check-in: <input type="date" name="checkin"><br>
- Check-out: <input type="date" name="checkout">
- <datalist id="count">
- <option value="1">
- <option value="2">
- <option value="3">
- <option value="4">
- </datalist>
- <input type="submit">
- </form>
- </body>
- </html>
- ---------------------------------------------------------------------------------------------
- page where the available room will be displayed
- myHotel.php
- <?php
- // 1. Enter the details of the database you need to connect
- $dbhost = 'localhost';
- $dbusr = 'root';
- $dbpswd = 'password';
- $dbname = 'name of database';
- // 2. now, create database connection
- $connection = mysql_connect($dbhost,$dbusr,$dbpswd);
- if (!$connection) {
- die("Couldn't connect to database: " . mysql_error());
- }
- // 3. Select the Database to connect
- $db_select = mysql_select_db($dbname,$connection);
- if (!$db_select) {
- die("Database selection failed: " . mysql_error());
- }
- $query = mysql_query("SELECT * FROM rooms_tbk WHERE checkout<'".$_POST["checkin"]."' ");
- while ($rows = mysql_fetch_array($query)) {
- $name = $rows['Name'];
- $roomType = $rows['roomType'];
- $image = $rows['imagePath'];
- $price = $rows['price'];
- $days=date_diff(.$_POST["checkin"].,.$_POST["checkout"].);
- $totalPrice=$days*$price;
- echo "$name<br>$roomType<br><image src='$image'/><br>$price<br>$totalPrice";
- }
- ?>
- <form action="submitDetails.php" method="post">
- <label id="name"> Full name:</label><br/>
- <input type="text" name="name"><br/>
- <label id="roomType"> Room Type:</label><br/>
- <input type="text" name="roomType"><br/>
- <button type="submit" name="save">save</button>
- </form>
- ----------------------------------------------------------------------------------------------------------------------------------
- SubmitDetails.php
- <?php
- if(isset($_POST['save'])){
- $sql = "INSERT INTO table (**values needed**)
- VALUES ('".$_POST["name"]."'**other values**";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment