This is the form:
<form>
<div class="form-group ">
<label for="exampleInputFirstName">First Name</label>
<input type="text" class="form-control" id="exampleInputFirstName" name="FirstName" placeholder="First Name">
</div>
<div class="form-group">
<label for="exampleInputLastName">Last Name</label>
<input type="text" class="form-control" id="exampleInputLastName" name="LastName" placeholder="Last Name">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" name="Email" aria-describedby="emailHelp" placeholder="Enter Email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword">Password</label>
<input type="password" class="form-control" id="exampleInputPassword" name="Password" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Confirm Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" name="confirmPassword" placeholder="Confirm Password">
</div>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
And this is the php:
<?php
$link = mysqli_connect("shareddb-i.hosting.stackcp.net", "LoginCredentials-3337b6db", "subrat410", "LoginCredentials-3337b6db");
if (mysqli_connect_error()) {
die ("There was an error connecting to the database");
}
if(isset($_POST['submit'])) {
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Email = $_POST['Email'];
$Password = $_POST['Password'];
$confirmPassword = $_POST['confirmPassword'];
}
$query ="INSERT INTO `Login-Credentials`( `FirstName`, `LastName`, `Email`, `Password`, `ConfirmPassword`) VALUES (' $FirstName ',' $LastName ',' $Email ',' $Password ',' $confirmPassword ')";
// $query = "UPDATE `LoginCredentials` SET password = 'uedjUFH7^%' WHERE email = 'robpercival80@gmail.com' LIMIT 1";
mysqli_query($link, $query);
?>
Every time I fill my form and submit, another empty row gets created in my database. Any help will be appreciated. I've implemented php.ini file and its not showing any type of error. Also, while viewing page source I see Undefined Index Error in my php code where I am declaring $FirstName=$_POST('FirstName') . Thank you