Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <html>
  2. <?php
  3.   require "../auth.php";
  4. ?>
  5. <head>
  6.     <meta charset="utf-8">
  7.     <title>Новая услуга</title>
  8. </head>
  9. <body>
  10. <form method="post" action="addservice.php">
  11.  
  12. Название услуги:<br>
  13. <input required type="text" name="service_name"><br>
  14. Цена:<br>
  15. <input required type="text" name="service_cost"><br>
  16. Использованные детали:<br>
  17. <?php   include_once("../dbconnect.php");
  18.  
  19. $result = mysql_query(" SELECT * FROM details ");
  20.  
  21. mysql_close();
  22. ?>
  23. <select name="detail_id" required>
  24.     <?php while($row = mysql_fetch_assoc($result)){ ?>
  25.     <option value="<?php echo $row['detail_id'] ?>" ><?php echo $row['name'] ?></option>
  26.     <?php } ?> 
  27. </select><br>
  28.    
  29. <input type="submit" name="add" value="Добавить">
  30. </form>
  31. <?php
  32.  
  33. include_once("../dbconnect.php");
  34.  
  35. if(isset($_POST['add'])){
  36.  
  37.   $service_name = strip_tags(trim($_POST['service_name']));
  38.   $service_cost = strip_tags(trim($_POST['service_cost']));
  39.   $detail_id = strip_tags(trim($_POST['detail_id']));
  40.  
  41.  
  42.   mysql_query(" INSERT INTO services(service_name, service_cost, detail_id)
  43.              VALUES ('$service_name','$service_cost','$detail_id') ");
  44.  
  45.   mysql_close();
  46.  
  47.   header("Location: services.php");
  48. }
  49.  
  50. ?>
  51. <a href="services.php">Вернуться назад</a>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement