Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Insert From Form</title>
- </head>
- <body>
- <form action="index.php" method="POST">
- <input type="text" name="one"/>
- <br>
- <input type="text" name="two"/>
- <br>
- <input type="submit" value="Submit"/>
- </form>
- </body>
- </html>
- <?php
- if(isset($_POST['one']) && isset($_POST['two']) &&!empty($_POST['one'])
- &&!empty($_POST['two'])){
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $dbname = "help";
- // Create connection
- $con = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$con) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $one = mysqli_real_escape_string($con, $_POST['one']);
- $two = mysqli_real_escape_string($con, $_POST['two']);
- $sql = "INSERT INTO value (one,two)
- VALUES('$one', '$two')";
- if (!mysqli_query($con, $sql)) {
- die("ERROR : ".mysqli_error($con));
- }
- else{
- echo "Done!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement