Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- this is index.php page -->
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <form action="insert.php" method="post">
- Name: <input type="text" name="username" /> <br />
- E-mail: <input type="text" name="email" /> <br />
- <input type="submit" value="Submit" name="submit" />
- </form>
- </body>
- </html>
- // this is insert.php page
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "tutorial";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $username = $_POST['username'];
- $email = $_POST['email'];
- $sql = "INSERT INTO PERSON (Name, Email) VALUES ('$username', '$email')";
- if (mysqli_query($conn, $sql)) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- ?>
Add Comment
Please, Sign In to add comment