My db connection is correct, I am able to select and echo out rows of my table. However, my form data isn't updating my database. I'm trying to submit the form on the same page, so I left the action blank. Here is my php:
<?php
if (isset($_POST['submit'])) {
$con=mysqli_connect("localhost","hey","password!","dbname");
$sql="INSERT INTO StudentList (StudentNum, LastName, FirstName, Address, City, State, Zip, Balance, FirstTermAttended)
VALUES('$_POST[inputID]','$_POST[inputLast]','$_POST[inputFirst]','$_POST[inputAddress]','$_POST[inputCity]','$_POST[inputState]','$_POST[inputZip]','$_POST[inputBalance]','$_POST[inputTerm]')";
echo "It worked";
}
?>
and here my form:
<form class="form-horizontal" role="form" method="post" action="">
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputID" placeholder="Student ID Number">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputLast" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputFirst" placeholder="First Name">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputAddress" placeholder="Street Address">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputCity" placeholder="City">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputState" placeholder="State">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputZip" placeholder="Zip">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputBalance" placeholder="Current Balance">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="text" class="form-control" id="inputTerm" placeholder="First Term Attended">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" value="Save Student Information" id="submit" name="submit" class="btn btn-primary">
</div>
</form>
I also have this in my header, could it be screwing things up?
<?php
// Create connection
$con=mysqli_connect("localhost","hey","password!","dbname");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>