Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "student";
  5. $password = "student";
  6. $database = "student_database";
  7.  
  8.  
  9. $conn = new mysqli($servername, $username, $password, $database);
  10.  
  11.  
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. } else
  15. echo "Connected successfully";
  16.  
  17.  
  18. echo '
  19. <html>
  20. <head>
  21. <title></title>
  22. </head>
  23. <body>
  24.  
  25. <form method = "GET" action = "index.php">
  26. <input type="text" name="film" placeholder="Naziv filma">
  27. <input type="text" name="redatelj" placeholder="Ime redatelja">
  28. <input type="text" name="glumac" placeholder="Ime glavnog glumca">
  29.  
  30.  
  31.  
  32. <select name = "getGenre">
  33. <option value="AF">Akcija</option>
  34. <option value="TR">Triler</option>
  35. <option value="LJF">Ljubavni</option>
  36. <option value="SF">Sci-fi</option>
  37. <option value="VS">Vestern</option>
  38. </select>
  39.  
  40. <input type="submit" name="">
  41. </form>
  42.  
  43.  
  44.  
  45. </body>
  46. </html>
  47.  
  48. ';
  49.  
  50. $value1 = $_GET["film"];
  51. $value2 = $_GET["redatelj"];
  52. $value3 = $_GET["glumac"];
  53. $value4 = $_GET["getGenre"];
  54.  
  55. $sql = "INSERT INTO Film (Ime, Redatelj, Glavni_glumac, Zanr)
  56. VALUES ( '".$value1."', '".$value2."', '".$value3."', '".$value4."')";
  57.  
  58. if ($conn->query($sql) === TRUE) {
  59. echo "New record created successfully";
  60. } else {
  61. echo "Error: " . $sql . "<br>" . $conn->error;
  62. }
  63.  
  64.  
  65.  
  66. $conn->close();
  67.  
  68.  
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement