Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connect =mysqli_connect('localhost', 'root', '','dane');
- $sql ="SELECT `id` from `rezyserzy` order by `id` desc limit 1";
- $result= $connect->query($sql);
- $row= mysqli_fetch_array($result);
- $rezyserzy=$row['id'];
- $rezyserzy++;
- if($_GET['tytul']!=null)
- {
- $tytul=$_GET['tytul'];
- $gatunek_filmu=$_GET['gatunek_filmu'];
- $rok_pro=$_GET['rok_produkcji'];
- $ocena=$_GET['ocena'];
- $sql = "INSERT INTO `filmy` (`gatunki_id`, `rezyserzy_id`, `tytul`, `rok`, `ocena`) values(\"$gatunek_filmu\", \"$rezyserzy\", \"$tytul\",\"$rok_pro\",\"$ocena\")";
- if($connect->query($sql) === TRUE)
- {
- echo "<script> alert(\"Dodano film\"); </script>";
- }
- else
- {
- echo "<script> alert(\"ERROR\ $sql.$connect->error\"); </script>";
- echo "Error: ".$sql."<br>".$connect->error;
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="pl">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta author="Artur Łomozik">
- <title>Filmy</title>
- </head>
- <body>
- <form action="index.php" method="GET">
- Tytul filmu: <input type="text" name="tytul" id="tytul"><br><br>
- Gatunek filmu: <select name="gatunek_filmu" id="gatunek_filmu">
- <option value="1">Sci-Fi</option>
- <option value="2">animacja</option>
- <option value="3">dramat</option>
- <option value="4">horror</option>
- <option value="5">komedia</option>
- </select><br><br>
- Rok produkcji: <input type="number" name="rok_produkcji" id="rok_produkcji"><br><br>
- Ocena: <input type="number" name="ocena" id="ocena"><br><br>
- <input type="submit" value="Dodaj">
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment