hello. I've got a form that submits to itself and then inserts entered data into a database.
<?php
$db_connection = mysql_connect('localhost', 'xxx', 'xxx') or die(mysql_error());
$db_select = mysql_select_db ('xxx') or die (mysql_error());
// if the form is submitted, process it
if (isset($submit)) {
$query = "insert into personaldetails values ('0','$family_name','$first_name','$title','$position','$company_name','$department','$address1','$address2','$address3','$country','$email_address','$fax_number','$telephone_number','$telephone_number2','$telephone_number3','$www_address')";
echo $family_name;
if (@mysql_query ($query)){
echo 'the member has been added';
}else {
echo 'there was a problem.'. mysql_error();
}
}
?>
<html>
<head>
<title>database admin - add a member</title>
</head>
<body>
<p>hello</p>
<form action="<?=$PHP_SELF ?>" method="post">
Last name: <input type="text" name="family_name" size="50" maxlength="50"><br>
First name: <input type="text" name="first_name" size="50" maxlength="50"><br>
Title: <input type="text" name="title" size="50" maxlength="50"><br>
Position: <input type="text" name="position" size="50" maxlength="50"><br>
Company Name: <input type="text" name="company_name" size="50" maxlength="50"><br>
Department: <input type="text" name="department" size="50" maxlength="50"><br>
Address1: <input type="text" name="address1" size="50" maxlength="50"><br>
Address2: <input type="text" name="address2" size="50" maxlength="50"><br>
Address3: <input type="text" name="address3" size="50" maxlength="50"><br>
Country: <input type="text" name="country" size="50" maxlength="50"><br>
Email Address: <input type="text" name="email_address" size="50" maxlength="50"><br>
Fax Number: <input type="text" name="fax_number" size="50" maxlength="50"><br>
Telephone Number: <input type="text" name="telephone_number" size="50" maxlength="50"><br>
Telephone Number2: <input type="text" name="telephone_number2" size="50" maxlength="50"><br>
Telephone Number3: <input type="text" name="telephone_number3" size="50" maxlength="50"><br>
Web Address: <input type="text" name="www_address" size="50" maxlength="50"><br>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
Basically what happens is that a new record is added to the database, but there is nothing in the fields, they are just empty. When i remove the $ before the variables in the INSERT command, the variable names are added into the fields, so i know that i have permissions to write to the data base.
I've never had this problem before and was wondering if anyone knew what was causing this. I can add a record manually but not through my script. I can also view that data using a php script, so it seems as though the only problem is writing it to the database.
Hope someone can help.
Thanks
KJ
PS the following are the field names in the table personaldetails...
familyName
firstName
title
position
companyName
department
address1
address2
address3
country
emailAddress
faxNumber
telephoneNumber
telephoneNumber2
telephoneNumber3
wwwAddress