hi,
im doing a really basic unvalidated form to a mysql db. i cant seem to find my error. just wonering if someone could help me out
any help would be greatly appreciated
heres the code:
<?php
if(!isset($POST['submit']))
{
?>
<html>
<head>
<title>Insert Test</title>
</head>
<body>
<h1>Insert Test</h1>
<form action = "<?$SERVER['PHP_SELF']?>" method = "post">
<ol><li> First Name<input type = "text" size = "20"name= "first_name" /></li>
<li>Last Name<input type = "text" size = "20" name = "last_name" /></li>
<li>Address Line 1<input type = "text" size = "20" name = "addr_line_one" /></li>
<li>Address Line 2<input type = "text" size = "20" name = "addr_line_two" /></li>
<li>Town<input type = "text" size = "20" name = "town" /></li>
<li>County<input type = "text" size = "20" name = "county" /></li>
<li>E-mail<input type = "text" size = "20" name = "email" /></li>
<li>Phone No<input type = "text" size = "20" name = "phone_no" /></li>
<li>Username<input type = "text" size = "20" name = "username" /></li>
<li><input type = "submit" name = "submit" value = "Click Here"></li>
</ol>
</form>
</body>
</html>
<?php
}
else
{
$db = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("buyer", $db);
$first_name = $_POST['first_name'];
$last_name= $_POST['last_name'];
$addr_line_one= $_POST['addr_line_one'];
$addr_line_two= $_POST['addr_line_two'];
$town= $_POST['town'];
$county= $_POST['county'];
$email= $_POST['email'];
$phone_no= $_POST['phone_no'];
$username= $_POST['username'];
$query = mysql_query("insert into buyer_table(first_name, last_name, addr_line_one, addr_line_two, town, county, email, phone_no, username)values('$first_name','$last_name', '$addr_line_one', '$addr_line_two', '$town', '$county', '$email', '$phone_no','$username')");
echo "Data has been succesfully entered";
}
?>