Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "student";
- $password = "student";
- $database = "student_database";
- $conn = new mysqli($servername, $username, $password, $database);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- } else
- echo "Connected successfully";
- echo '
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form method = "GET" action = "index.php">
- <input type="text" name="film" placeholder="Naziv filma">
- <input type="text" name="redatelj" placeholder="Ime redatelja">
- <input type="text" name="glumac" placeholder="Ime glavnog glumca">
- <select name = "getGenre">
- <option value="AF">Akcija</option>
- <option value="TR">Triler</option>
- <option value="LJF">Ljubavni</option>
- <option value="SF">Sci-fi</option>
- <option value="VS">Vestern</option>
- </select>
- <input type="submit" name="">
- </form>
- </body>
- </html>
- ';
- $value1 = $_GET["film"];
- $value2 = $_GET["redatelj"];
- $value3 = $_GET["glumac"];
- $value4 = $_GET["getGenre"];
- $sql = "INSERT INTO Film (Ime, Redatelj, Glavni_glumac, Zanr)
- VALUES ( '".$value1."', '".$value2."', '".$value3."', '".$value4."')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement