I cannot get my code to work. I'm new to php/mysql but I am certain I am doing most things right here. I'm not getting any errors. With the code posted below, if I put info into the feilds and click the button the screen appears to refresh but when I check the mysql database I created, that info is not there. I know that my connection to the database is working because I have fake data already entered into the database and the webpage is pulling it over and displaying it just fine.
The db.php is a separate file that contains the formatted php code for connecting to the database (server, username, password), which I know works because that is how I pull the data into the webpage as well. And if it is needed, my server is set up for php 4.0.10.7 and I can't change that unfortunately.
So, here is my code:
<div class="a" id="add_customer">
<form id="customerdata" name="customerdata">
<input type="text" align="center" id="name" name="NAME" placeholder="Customer Name">
<input type="text" align="center" id="address" name="ADDRESS" placeholder="Address">
<b>Paid?:</b>
<select id="PAID" name="PAID">
<option value="select">Make a Selection</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<input type="text" align="center" id="comments" name="COMMENTS" placeholder="Comments">
<input type="submit" id="submit" name="submit" value="Add Customer">
</form>
</div>
<?php
if(isset($_POST['submit']))
{
include('db.php');
$database="mysql_database";
$con = mysql_connect($server,$username,$password);
$sql="INSERT INTO mysql_database (NAME, ADDRESS, PAID, COMMENTS)
VALUES
('$_POST[NAME]','$_POST[ADDRESS]','$_POST[PAID]','$_POST[COMMENTS]')";
$a=mysql_query($sql);
if (!$a)
{
die("Error addding record. " . mysql_error());
}
else
{
echo "1 record added";
}
mysql_close($con);
}
?>