Hey im trying to create a registartion form and its allmost there,
The user can input there data
php connects to mysql and the database
it fails when trying to run the sql query i create this is the first time iv tried to edit a table through php and cant see whats going wrong.
Here is the actual sql statement:
$sql = "insert into customer
(Cust_ID, User_Name, Password, First_Name, Last_Name, Email) values
(\"$customerid\", \"$username\", password(\"$password\"),\"$firstname\",\"$lastname\",\"email\" )";
$result = @mysql_query( $sql, £conn )
or die("Could not execute query");
this i where it goes wrong everytime iv checked that the clumon names and variables are typed in correct in other than that im completly lost so any help would be great my full code is below
<html><head><title>Register</title></head><body>
<?php $self = $_SERVER['PHP_SELF'];
$customerid = $_POST['customerid'];
$username = $_POST['username'];
$password = $_POST['password'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
if( ( !$username ) or ( !$password ) or ( !$firstname ) or ( !$lastname ) or ( !$email ) )
{
$form ="Please Enter The Following Details To Create An Account";
$form.="<form action=\"$self\" ";
$form.=" method=\"post\"> Customer ID: ";
$form.="<input type=\"text\" name=\"customerid\" ";
$form.=" value=\"$customerid\"> <br>User Name: ";
$form.="<input type=\"text\" name=\"username\" ";
$form.=" value=\"$username\"> <br>Password: ";
$form.="<input type=\"text\" name=\"password\" ";
$form.="value=\"$password\"> <br>First Name: ";
$form.="<input type=\"text\" name=\"firstname\" ";
$form.="value=\"$firstname\"> <br>Last Name: ";
$form.="<input type=\"text\" name=\"lastname\" ";
$form.="value=\"$lastname\"> <br>Email: ";
$form.="<input type=\"text\" name=\"email\" ";
$form.="value=\"$email\"> <br>";
$form.="<input type=\"submit\" value=\"Submit\">";
$form.="</form>";
echo( $form );
}
else
{
$conn = @mysql_connect( "localhost", "root", "")
or die("could not make the connection");
$db = @mysql_select_db( "store", $conn )
or die("could not connect to database");
$sql = "insert into customer
(Cust_ID, User_Name, Password, First_Name, Last_Name, Email) values
(\"$customerid\", \"$username\", password(\"$password\"),\"$firstname\",\"$lastname\",\"email\" )";
$result = @mysql_query( $sql, £conn )
or die("Could not execute query");
if( $result )
{
echo( " New user $username added" ); }
}
?>
</body></html>
</body>
</html>
the error code "or die("Could not execute query");" is what keeps displaying after i enter the data and click submit so it is getting pretty far through the code but crashes out on this last bit