Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------ВВОД ДАННЫХ-------------------------
- <html>
- <head>
- <title> Furniture store - Search directory </title>
- </head>
- <body>
- <h1> Furniture store - Search directory </h1>
- <form action="results1.php" method="POST">
- Select your search criteria:<br>
- <select name="searchtype">
- <option value="country">Producting country
- <option value="type">Type of furniture
- <option value="code">Code
- </select>
- <br>
- Enter your search string:<br>
- <input name="searchterm" type=text>
- <br>
- <input type=submit value="Search">
- </form>
- </body></html>
- ---------ВЫВОД РЕЗУЛЬТАТОВ И ВВОД ДАННЫХ ЗАКАЗОВ ДЛЯ ЗАПИСИ В БД------------------
- <html>
- <head>
- <title> Furniture store - Searching results </title>
- </head>
- <body>
- <h1> Furniture store - Searching results </h1>
- <form action="order.php" method="POST">
- <?
- $searchtype = $_REQUEST['searchtype'];
- $searchterm = $_REQUEST['searchterm'];
- if (!$searchtype || !$searchterm) {echo "Enter all data. Try again.";
- exit;
- }
- $searchtype = addslashes($searchtype);
- $searchterm = addslashes($searchterm);
- @ $db = mysql_pconnect("localhost", "root", "");
- if (!$db) {
- echo " Error. Cant connect to database. Try again later.";
- exit;
- }
- mysql_select_db("furniture_store");
- $query = "select * from furniture where ".$searchtype." like '%".$searchterm."%'";
- $result = mysql_query($query);
- $num_results = mysql_num_rows($result);
- echo "<p>Amount of furniture found: ".$num_results."</p>";
- for ($i=0; $i <$num_results; $i++) {
- $row = mysql_fetch_array($result);
- echo "<p><strong>".($i+1).". Name: ";
- echo stripslashes($row["Type"]);
- echo "</strong><br>Country: ";
- echo stripslashes($row["Country"]);
- echo "<br>Code: ";
- echo stripslashes($row["Code"]);
- echo "<br>Price: ";
- echo stripslashes($row["Price"]);
- echo "</p>";
- }
- ?>
- <table border=0>
- <tr><td>Order ID</td><td><input type=text name=orderid maxlength=13
- size=13><br> </td></tr>
- <tr><td>Customer ID</td><td><input type=text name=customerid maxlength=13
- size=13><br> </td></tr>
- <tr><td>Price</td><td><input type=text name=amount maxlength=30
- size=30><br> </td> </tr>
- <tr><td>Code</td><td><input type=text name=code maxlength=7
- size=7><br> </td></tr>
- <tr><td>Availability</td><td><input type=text name=availability maxlength=7
- size=7><br> </td></tr>
- <tr><td colspan=2><input type=submit value="To order"></td></tr>
- </table>
- </form>
- </body>
- </html>
- ---------------ФАЙЛ, КОТОРЫЙ ВНОСИТ ВВЕДЕННЫЕ ВЫШЕ ДАННЫЕ В ТАБЛИЦУ ПОКУПАТЕЛЕЙ------------------
- <html>
- <head>
- <title> Furniture store - Result of adding customers </title>
- </head><body>
- <h1> Furniture store - Result of adding customers</h1>
- <?
- $orderid =$_REQUEST[orderid];
- $customerid =$_REQUEST[customerid];
- $amount =$_REQUEST[amount];
- $code =$_REQUEST[code];
- $availability =$_REQUEST[availability];
- if (!$customerid || !$orderid || !$amount || !$code || !$availability) {
- echo "Enter all data.<br>"
- ."Try again.";
- exit;
- }
- $customerid = addslashes($customerid);
- $orderid = addslashes($orderid);
- $amount = addslashes($amount);
- $code = addslashes($code);
- $availability = addslashes($availability);
- @ $db = mysql_pconnect("localhost", "root", "");
- if (!$db) {
- echo "Error. Cant connect to database. Try again later.";
- exit;
- }
- mysql_select_db("furniture_store");
- $query = "insert into ordesrs values ('".$customerid."', '".$orderid."', '".$code."','".$amount."', '".$availability."')";
- $result = mysql_query($query);
- if ($result)echo mysql_affected_rows()." Orders added to the database.";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment