Guest User

Untitled

a guest
Jul 21st, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. ----------------------ВВОД ДАННЫХ-------------------------
  2.  
  3. <html>
  4. <head>
  5. <title> Furniture store - Search directory </title>
  6. </head>
  7. <body>
  8. <h1> Furniture store - Search directory </h1>
  9. <form action="results1.php" method="POST">
  10. Select your search criteria:<br>
  11. <select name="searchtype">
  12. <option value="country">Producting country
  13. <option value="type">Type of furniture
  14. <option value="code">Code
  15. </select>
  16. <br>
  17. Enter your search string:<br>
  18. <input name="searchterm" type=text>
  19. <br>
  20. <input type=submit value="Search">
  21. </form>
  22. </body></html>
  23.  
  24. ---------ВЫВОД РЕЗУЛЬТАТОВ И ВВОД ДАННЫХ ЗАКАЗОВ ДЛЯ ЗАПИСИ В БД------------------
  25.  
  26. <html>
  27. <head>
  28. <title> Furniture store - Searching results </title>
  29. </head>
  30. <body>
  31. <h1> Furniture store - Searching results </h1>
  32. <form action="order.php" method="POST">
  33. <?
  34. $searchtype = $_REQUEST['searchtype'];
  35. $searchterm = $_REQUEST['searchterm'];
  36. if (!$searchtype || !$searchterm) {echo "Enter all data. Try again.";
  37. exit;
  38. }
  39. $searchtype = addslashes($searchtype);
  40. $searchterm = addslashes($searchterm);
  41. @ $db = mysql_pconnect("localhost", "root", "");
  42. if (!$db) {
  43. echo " Error. Cant connect to database. Try again later.";
  44. exit;
  45. }
  46. mysql_select_db("furniture_store");
  47. $query = "select * from furniture where ".$searchtype." like '%".$searchterm."%'";
  48. $result = mysql_query($query);
  49. $num_results = mysql_num_rows($result);
  50. echo "<p>Amount of furniture found: ".$num_results."</p>";
  51. for ($i=0; $i <$num_results; $i++) {
  52. $row = mysql_fetch_array($result);
  53. echo "<p><strong>".($i+1).". Name: ";
  54. echo stripslashes($row["Type"]);
  55. echo "</strong><br>Country: ";
  56. echo stripslashes($row["Country"]);
  57. echo "<br>Code: ";
  58. echo stripslashes($row["Code"]);
  59. echo "<br>Price: ";
  60. echo stripslashes($row["Price"]);
  61. echo "</p>";
  62. }
  63. ?>
  64. <table border=0>
  65. <tr><td>Order ID</td><td><input type=text name=orderid maxlength=13
  66. size=13><br> </td></tr>
  67. <tr><td>Customer ID</td><td><input type=text name=customerid maxlength=13
  68. size=13><br> </td></tr>
  69. <tr><td>Price</td><td><input type=text name=amount maxlength=30
  70. size=30><br> </td> </tr>
  71. <tr><td>Code</td><td><input type=text name=code maxlength=7
  72. size=7><br> </td></tr>
  73. <tr><td>Availability</td><td><input type=text name=availability maxlength=7
  74. size=7><br> </td></tr>
  75. <tr><td colspan=2><input type=submit value="To order"></td></tr>
  76. </table>
  77. </form>
  78. </body>
  79. </html>
  80.  
  81. ---------------ФАЙЛ, КОТОРЫЙ ВНОСИТ ВВЕДЕННЫЕ ВЫШЕ ДАННЫЕ В ТАБЛИЦУ ПОКУПАТЕЛЕЙ------------------
  82.  
  83. <html>
  84. <head>
  85. <title> Furniture store - Result of adding customers </title>
  86. </head><body>
  87. <h1> Furniture store - Result of adding customers</h1>
  88. <?
  89. $orderid =$_REQUEST[orderid];
  90. $customerid =$_REQUEST[customerid];
  91. $amount =$_REQUEST[amount];
  92. $code =$_REQUEST[code];
  93. $availability =$_REQUEST[availability];
  94. if (!$customerid || !$orderid || !$amount || !$code || !$availability) {
  95. echo "Enter all data.<br>"
  96. ."Try again.";
  97. exit;
  98. }
  99. $customerid = addslashes($customerid);
  100. $orderid = addslashes($orderid);
  101. $amount = addslashes($amount);
  102. $code = addslashes($code);
  103. $availability = addslashes($availability);
  104. @ $db = mysql_pconnect("localhost", "root", "");
  105. if (!$db) {
  106. echo "Error. Cant connect to database. Try again later.";
  107. exit;
  108. }
  109. mysql_select_db("furniture_store");
  110. $query = "insert into ordesrs values ('".$customerid."', '".$orderid."', '".$code."','".$amount."', '".$availability."')";
  111. $result = mysql_query($query);
  112. if ($result)echo mysql_affected_rows()." Orders added to the database.";
  113. ?>
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment