MySQL Forums :: PHP :: Checking for exact match in row


Advanced Search

Checking for exact match in row
Posted by: cameron stevenson ()
Date: July 11, 2009 06:08AM

I have a php script:

<?php
$userlen=strlen($_POST['rn']);
$passlen=strlen($_POST['rp']);
if ($userlen<7)
{
header("refresh: 1; index.php?a=login");
echo 'Username is Too short';
}
elseif ($passlen<7)
{
header("refresh: 1; index.php?a=login");
echo 'Password is Too Short';
}
elseif ($_POST['rp']==$_POST['rr'])
{
$pass=md5($_POST['rp']);
$user=$_POST['rn'];
include('mysql_connect.php'); //CONNECTS TO SERVER AND SELECTS DATABASE
$ch=mysql_query("SELECT * FROM users WHERE username='".$user."'");
$chc=mysql_fetch_array($ch);
if (!$ch=='')
{
header("refresh: 1; index.php?a=login");
echo 'Username is in use';
}
else
{
header("refresh: 5; index.php?a=login");
echo 'You are now registered<br>You can log in using<br>the username you signed up with';
mysql_query("INSERT INTO users (username, password) VALUES ('".$user."','".$pass."')
");

}
}
else
{
header("refresh: 1; index.php?a=login");
echo 'Passwords do not match';
}
?>


on the previous page you submit a registration with username and password twice(rn,rp,rr)(regstername,registerpass,registerrepeat)

the problem is, if a username is already in the database, and the new one is close to the one in the database, the code says that the username already exists

Options: ReplyQuote


Subject Written By Posted
Checking for exact match in row cameron stevenson 07/11/2009 06:08AM
Re: Checking for exact match in row Hartmut Holzgraefe 07/12/2009 01:00AM
Re: Checking for exact match in row cameron stevenson 07/12/2009 08:47AM
Re: Checking for exact match in row Hartmut Holzgraefe 07/12/2009 11:49AM
Re: Checking for exact match in row Rick James 07/12/2009 07:02PM
Re: Checking for exact match in row cameron stevenson 07/13/2009 09:00AM
Re: Checking for exact match in row Rick James 07/13/2009 08:41PM
Re: Checking for exact match in row Hartmut Holzgraefe 07/14/2009 01:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.