[SOLVED] Verify username
Posted: Tue Mar 30, 2004 1:08 am
HI Cool people
I am new to the whole PHP thing and need some help with a simple form. The form is used to input data into a customer database and email the results of the input to the HR dept.
The forms work well but I need to check whether a usename allready exists in the database, and if so either die or direct the user to the form for editing user data.
Here is what I came up with:
Admin Edit: Added tags and edited code (added spaces) so that it could wrap.][/size][/color]
The script runs without any errors but it still allows duplicate entries in the name field.
Any sugestions?
Thanks
I am new to the whole PHP thing and need some help with a simple form. The form is used to input data into a customer database and email the results of the input to the HR dept.
The forms work well but I need to check whether a usename allready exists in the database, and if so either die or direct the user to the form for editing user data.
Here is what I came up with:
Admin Edit: Added
Code: Select all
Code: Select all
$link = mysql_connect("localhost","user1","*********");
mysql_select_db("dealerdb",$link);
$query = "SELECT *" .
"FROM client_info" .
"WHERE name = "$BusinessName";";
$result = mysql_query($query);
if ($result) {
die("Username taken");
} else {
$query="insert into client_info (name, industry, contact, position, oh_tel, ah_tel, fax, mobile, email, dob, interest, sale_status, sale_type, bike, car, cust_type) values ('".$BusinessName."', '".$Industry."', '".$ContactName."', '".$Position."', '".$TelNoOfficeHours."', '".$TelNoAfterHours."', '".$FaxNo."', '".$MobileNo."', '".$EmailAddress."', '".$DateOfBirth."', '".$MainInterest."', '".$SaleStatus."', '".$SaleType."', '".$BikeCustomer."', '".$CarCustomer."', '".$CustomerType."')";
mysql_query($query);
header("Refresh: 0;url=http://localhost/dealerdb");
}
?>Any sugestions?
Thanks