grover1311
03-29-2007, 6:52 AM
i am making a basic user script and i am wondering how to check if a user name already exists in my database?
<?
//this is register script that will insert users into tables created in install.php
//variables will be below.
$usernames=$_post['username'];
$password=$_post['password'];
$email=$_post['email'];
$location=$_post['location'];
$checkpassword=$_post['checkpassword'];
$name=$_post['name'];
$age=$_post['age'];
//mysql variables (username,password,localhost)
$username='';
$password='';
$database='';
//check if both passwords are same if they are insert to database
if ($password == $checkpassword) }
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query2 = "INSERT INTO contacts VALUES ('','$username','$name','$age','$email','$password ',')";
mysql_query($query2);
mysql_close();
}else{
echo 'Passwords do not match.';
?>
<?
//this is register script that will insert users into tables created in install.php
//variables will be below.
$usernames=$_post['username'];
$password=$_post['password'];
$email=$_post['email'];
$location=$_post['location'];
$checkpassword=$_post['checkpassword'];
$name=$_post['name'];
$age=$_post['age'];
//mysql variables (username,password,localhost)
$username='';
$password='';
$database='';
//check if both passwords are same if they are insert to database
if ($password == $checkpassword) }
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query2 = "INSERT INTO contacts VALUES ('','$username','$name','$age','$email','$password ',')";
mysql_query($query2);
mysql_close();
}else{
echo 'Passwords do not match.';
?>