There is a page called form.html .It directs to the page addtodatabase.php at the end there is submit button .
<form action="addtodatabase.php" method="post">
<form class="form-inline">
<fieldset>
<legend>Security Department User Registration</legend>
<div class="form-group">
<label for="Firstname">First Name</label>
<input type="text" class="form-control" id="Firstname" name="firstname" placeholder="Text input"><br/>
</div>
<div class="form-group">
<label for="Secondname">Second Name</label>
<input type="text" class="form-control" id="Secondname" name="secondname" placeholder="Text input"><br/>
</div>
</form>
My addtodatabase.php page .
$connect=mysqli_connect('localhost','root','','form_db');
if(mysqli_connect_errno($connect))
{
echo 'Failed to connect:'.mysqli_connect_error();
}
$firstname="";
$secondname="";
if (isset($_POST)) {
$firstname = isset($_POST['firstname']) ? $_POST['firstname'] : '';
$secondname = isset($_POST['secondname']) ? $_POST['secondname'] : '';
echo 'Your first name is ' .$firstname. '<br>';
echo 'Your second name is ' .$secondname. '<br>';
}
There are three errors
it doesn't get to the page
addtodatabase.php
. http://localhost:8080/form/form.html?
Notice: Undefined index: firstname in C:\wamp64\www\Form\addtodatabase.php on line 12. nothing is being added to database. only id is increment
Thanks in advance.