I can connect to the database, but cannot get the data to successfully get entered into the database.
My form looks like this:
- Code: Select all
<form action="submit_info.php" method="post">
<ul>
<li>
<p class="left">
<label for="first_name"></label>
<input type="text" name="first_name" placeholder="First Name" />
</p>
<p class="pull-right">
<label for="last_name"></label>
<input type="text" name="last_name" placeholder="Last Name" />
</p>
</li>
<li>
<p>
<label for="email"> <span class="req"></span></label>
<input type="email" name="email" placeholder="Your Email " />
</p>
</li>
<li>
<p>
<input type="text" name="phone_number" placeholder="Phone Number" />
</p>
</li>
<li><div class="divider"></div></li>
<li>
<label for="comments">Comments</label>
<textarea cols="46" rows="3" name="comments"></textarea>
</li>
<li>
<input class="btn btn-submit" type="submit" value="Submit" />
</li>
</ul>
</form>
The connect page, mysqli_connect.php, which works, is like this:
- Code: Select all
<?php
$servername = "127.0.0.1";
$username = "jerrittpace";
$password = "553597";
$dbname = "contact_me_jerrittpace.com";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
Then the submit_info.php page, which I can't get to work, is:
- Code: Select all
<?php
include 'mysqli_connect.php';
if(isset($_POST["submit"])){
$sql = "INSERT INTO persons (first_name, last_name, email, phone_number, comments)
VALUES ('".$_POST["first_name"]."','".$_POST["last_name"]."','".$_POST["email"]."', '".$_POST["phone_number"]."', '".$_POST["comments"]."')";
}
?>
My database (named contact_me_jerrittpace.com) is set up like this:
1 ID int(100) UNSIGNED No None Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
Spatial Spatial
Fulltext Fulltext
Distinct values Distinct values
2 first_name text No None Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
Spatial Spatial
Fulltext Fulltext
Distinct values Distinct values
3 last_name text No None Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
Spatial Spatial
Fulltext Fulltext
Distinct values Distinct values
4 email varchar(100) No None Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
Spatial Spatial
Fulltext Fulltext
Distinct values Distinct values
5 phone_number varchar(15) No None Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
Spatial Spatial
Fulltext Fulltext
Distinct values Distinct values
6 comments varchar(500) No None Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
Spatial Spatial
Fulltext Fulltext
Distinct values Distinct values
With selected:Check allWith selected:
I appreciate any help anyone can offer!!
[EDIT by Altrea: changed the subject (yes, you can edit your own post here) and wrapped your code in php BB-Tags]