Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- </head>
- <body>
- <h1>Add_data.php</h1>
- <?php
- $servername = "localhost";
- $username = "root"; //root is default user
- $password = ""; //default pw is blank
- $dbName = "moviesdb"; //database name
- //create connection
- $conn = mysqli_connect($servername, $username, $password, $dbName);
- //check connection
- if(!$conn) {
- die("Connection Failed:" . mysqli_connect_error());
- }
- echo "Connected Successfully! <br>";
- //get data from Form index.html
- $id = $_GET['MovieID'];
- $name = $_GET['MovieName'];
- $description = $_GET['MovieDescription'];
- // $name = $_GET['name'];
- // $alterego = $_GET['alterego'];
- // $gender = $_GET['gender'];
- // $power = $_GET['power'];
- //make sql insert statement
- $sql = "INSERT into movies(MoviesID, MovieName,MovieDescription)
- values(". $id .",'". $name ."','". $description ."');"
- //write the data to the database
- if(mysqli_query($conn, $sql)){
- echo "<h1>Records ADDED successfully.<br>";
- echo "<a href='add_data.html'>ADD another?</a></h1>";
- }
- else {
- echo "<h1>ERROR: Unable to execute $sql. " . mysqli_error($conn);
- mysqli_error($conn);
- echo "<br><a href='add_data.html'>ADD another?</a></h1>";
- // echo "<h1><a href='displayinfo.php'>Display Records</a></h1>";
- }
- mysqli_close($conn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement