This question already has an answer here:
I am currently trying to take information from a user text form and send it to my database. I am working with Xampp. Here is a snippet of my form to get the user data.
<div id="section-clientinformation" class="tab-content">
<div class="tab-pane fade in active">
<h2>Client Information</h2>
<p>Please enter your information. All information will be stored into our database.</p>
<form action = "/db_connection_clientinfo.php" method=post">
First name: <input class= "from control item" type="text" name="FirstName" maxlength="15" minlength="3" id="firstname" placeholder="name" required><br>
Last name: <input class= "from control item" type="text" name="LastName"maxlength="15" minlength="3" id="lastname" placeholder="lastname" required><br>
Address: <input type="text" name="Address" minlength="7" id="address" placeholder="use complete address" required>
<br>
City: <input type="text" name="City" minlength="2" id="city" placeholder="city" required>
<br>
State: <input type="text" name="State" maxlength="2" id="state" placeholder="state" required>
<br>
Zip: <input type="text" name="Zip" maxlength="5" id="zip" placeholder="zip code" required>
<br>
Phone: <input type="text" name="Phone" minlength="7" id="phone" placeholder="(xxx) xxx-xxxx" required>
<br>
Email: <input type="text" name="Email" minlength="7" id="email" placeholder="xxxx@email.com"
required>
<br>
<input type="submit" value="Add Client" name="addclient">
</form>
</div>
Here is my db_connection_clientinfo.php file.
<?php
$dbhost = "localhost";
$dbuser = "root";
$pass = "";
$db = "FuelCalcDB";
$conn = new mysqli($dbhost, $dbuser, $pass, $db) or die("Connect failed: %s
");
if($conn === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
else {
echo "Online";
}
$first_name = $_POST['FirstName'];
$last_name = $_POST['LastName'];
$address = $_POST['Address'];
$city = $_POST['City'];
$state = $_POST['State'];
$zipcode = $_POST['Zip'];
$phone = $_POST['Phone'];
$email = $_POST['Email'];
$query = "INSERT INTO clientInformation (firstname, lastname, address, city, state, zipcode, phone, email) VALUES('$first_name','$last_name','$address','$city','$state','$zipcode','$phone','$email')";
$result = mysqli_query($conn, $query);
if($result)
{
echo "Records added Successfully.";
} else{
echo "ERROR";
}
mysqli_close($conn);
?>
I don't know where i'm going wrong but when I select add client, I get an 'Object not found error'
Could someone please shed some light on my problem. Thank you
</div>