jaredec18

Untitled

Sep 20th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. -----------Home Page--------------
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <title>My Hotel</title>
  7. <style>
  8. body {
  9. background-color: green;
  10. text-align: center;
  11. color: white;
  12. font-family: Arial, Helvetica, sans-serif;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <h1>My Hotel</h1>
  18. <p>This is the address of My Hotel.</p>
  19. <p>other details like e-mail, ph. no. etc</p>
  20. <img src="hotel.png" alt="MyHotel" style="width:200px">
  21. <form action="myHotel.php" method="post">
  22. Name: <input type="text" name="name"><br>
  23. E-mail: <input type="text" name="email"><br>
  24. No Of Rooms: <input list="count" type="text" name="rooms"><br>
  25. No Of Adults: <input list="count" type="text" name="adults"><br>
  26. No Of Children: <input list="count" type="text" name="children"><br>
  27. Check-in: <input type="date" name="checkin"><br>
  28. Check-out: <input type="date" name="checkout">
  29. <datalist id="count">
  30. <option value="1">
  31. <option value="2">
  32. <option value="3">
  33. <option value="4">
  34. </datalist>
  35. <input type="submit">
  36. </form>
  37. </body>
  38. </html>
  39.  
  40. ---------------------------------------------------------------------------------------------
  41.  
  42. page where the available room will be displayed
  43.  
  44. myHotel.php
  45.  
  46. <?php
  47. // 1. Enter the details of the database you need to connect
  48. $dbhost = 'localhost';
  49. $dbusr = 'root';
  50. $dbpswd = 'password';
  51. $dbname = 'name of database';
  52.  
  53. // 2. now, create database connection
  54. $connection = mysql_connect($dbhost,$dbusr,$dbpswd);
  55. if (!$connection) {
  56. die("Couldn't connect to database: " . mysql_error());
  57. }
  58.  
  59. // 3. Select the Database to connect
  60. $db_select = mysql_select_db($dbname,$connection);
  61. if (!$db_select) {
  62. die("Database selection failed: " . mysql_error());
  63. }
  64.  
  65. $query = mysql_query("SELECT * FROM rooms_tbk WHERE checkout<'".$_POST["checkin"]."' ");
  66.  
  67. while ($rows = mysql_fetch_array($query)) {
  68. $name = $rows['Name'];
  69. $roomType = $rows['roomType'];
  70.  
  71. $image = $rows['imagePath'];
  72.  
  73. $price = $rows['price'];
  74.  
  75. $days=date_diff(.$_POST["checkin"].,.$_POST["checkout"].);
  76.  
  77. $totalPrice=$days*$price;
  78.  
  79. echo "$name<br>$roomType<br><image src='$image'/><br>$price<br>$totalPrice";
  80. }
  81.  
  82. ?>
  83.  
  84. <form action="submitDetails.php" method="post">
  85. <label id="name"> Full name:</label><br/>
  86. <input type="text" name="name"><br/>
  87. <label id="roomType"> Room Type:</label><br/>
  88. <input type="text" name="roomType"><br/>
  89. <button type="submit" name="save">save</button>
  90. </form>
  91.  
  92. ----------------------------------------------------------------------------------------------------------------------------------
  93.  
  94. SubmitDetails.php
  95.  
  96. <?php
  97. if(isset($_POST['save'])){
  98. $sql = "INSERT INTO table (**values needed**)
  99. VALUES ('".$_POST["name"]."'**other values**";
  100. }
  101.  
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment