i am having trouble inserting my form into mysql. for some reason its not working and displaying this message:
Notice: Undefined index: company_name in C:\xampp\htdocs\hewden_spms\supplier_function\registration_complete.php on line 15
Notice: Undefined index: company_reg_number in C:\xampp\htdocs\hewden_spms\supplier_function\registration_complete.php on line 16
ERROR
can someone show me where i am going wrong please, i have 9 columns in my table but only want to insert company_name and company_reg_number at the minute. so i thought i was doing this right but clearly im missing something.
heres my html:
<form name="myForm" id="myform" action="registration_complete.php" onsubmit="return validateForm()" method="post">
<input type="text" name="cname">
<input type='text' name='creg'>
<input type="submit" id="postme" value="Submit">
php:
<?php
session_start();
$db_hostname = 'localhost';
$db_database = 'hewden1';
$db_username = 'root';
$db_password = '';
$db_server = mysql_connect($db_hostname, $db_username, $db_password)
or die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database)
or die("Unable to select database: " . mysql_error());
$cname = $_POST['company_name'];
$creg = $_POST['company_reg_number'];
$sql="INSERT INTO supplier_registration (null, company_name, company_reg_number, null, null, null, null, null, null)
VALUES ('$cname', '$cname')";$result = mysql_query($sql);
if($result){
echo "jobs a gooden";
}else {
echo "ERROR";
}
?>
database structure:
table = supplier_registration
column 1 = id
column 2 = company_name
column 3 = company_reg_number
column 4 = address
column 5 = postcode
column 6 = email
column 7 = name
column 8 = vat
column 9 = age