BestCoderInZSL

Dla debili

Oct 4th, 2021 (edited)
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. $connect =mysqli_connect('localhost', 'root', '','dane');
  3. $sql ="SELECT `id` from `rezyserzy` order by `id` desc limit 1";
  4. $result= $connect->query($sql);
  5. $row= mysqli_fetch_array($result);
  6.     $rezyserzy=$row['id'];
  7.     $rezyserzy++;
  8.  
  9. if($_GET['tytul']!=null)
  10. {
  11.     $tytul=$_GET['tytul'];
  12.     $gatunek_filmu=$_GET['gatunek_filmu'];
  13.     $rok_pro=$_GET['rok_produkcji'];
  14.     $ocena=$_GET['ocena'];
  15.     $sql = "INSERT INTO `filmy` (`gatunki_id`, `rezyserzy_id`, `tytul`, `rok`, `ocena`) values(\"$gatunek_filmu\", \"$rezyserzy\", \"$tytul\",\"$rok_pro\",\"$ocena\")";
  16.     if($connect->query($sql) === TRUE)
  17.     {
  18.         echo  "<script> alert(\"Dodano film\"); </script>";
  19.     }
  20.     else
  21.     {
  22.         echo  "<script> alert(\"ERROR\ $sql.$connect->error\"); </script>";
  23.         echo "Error: ".$sql."<br>".$connect->error;
  24.     }
  25. }
  26.  
  27. ?>
  28.  
  29. <!DOCTYPE html>
  30. <html lang="pl">
  31. <head>
  32.     <meta charset="UTF-8">
  33.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  34.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  35.     <meta author="Artur Łomozik">
  36. <title>Filmy</title>
  37. </head>
  38. <body>
  39.     <form action="index.php" method="GET">
  40.         Tytul filmu: <input type="text" name="tytul" id="tytul"><br><br>
  41.         Gatunek filmu: <select name="gatunek_filmu" id="gatunek_filmu">
  42.             <option value="1">Sci-Fi</option>
  43.             <option value="2">animacja</option>
  44.             <option value="3">dramat</option>
  45.             <option value="4">horror</option>
  46.             <option value="5">komedia</option>
  47.         </select><br><br>
  48.         Rok produkcji: <input type="number" name="rok_produkcji" id="rok_produkcji"><br><br>
  49.         Ocena: <input type="number" name="ocena" id="ocena"><br><br>
  50.         <input type="submit" value="Dodaj">
  51.     </form>
  52. </body>
  53. </html>
Add Comment
Please, Sign In to add comment