Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- index.html-->
- <form action="process.php" method="post">
- <input type="text" name="first_name" placeholder="First Name" /><br/>
- <input type="text" name="last_name" placeholder="Last Name" /><br/>
- <button type="submit" name="submit"></button>
- </form>
- //database.php
- $dbhost = "localhost";
- $dbuser = "root";
- $dbpass = "xxxx";
- $dberror1 = "Could not connect to the database!";
- $dberror2 = "Could not find selected table!";
- // Connection to the database, Already tried this with echo statement and works
- $conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die ($dberror1);
- // Selecting the database to connect to
- $select_db = mysqli_select_db($conn, 'mainbase') or die ($dberror2);
- //process.php
- <?php include 'database.php';
- if(isset($_POST['submit'])) {
- // Creating variables to store form values
- $first_name= $_POST['first_name'];
- $last_name=$_POST['last_name'];
- //Executing the query
- mysqli_query($conn, " INSERT INTO 'candidates'('first_name', 'last_name') //Values in 'candidates' table on phpmyadmin
- VALUES ('$first_name','$last_name')");/*variables from above*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement