Hi all,
I have created a register page(register.htm) and when the user clicks submit the welcome pg is called(welcome.php).
However, for some reason I cannot register any name. The message I get is:
select * from user where username=''
1That username is taken - go back and choose another one.
Here is some code on my welcome pg:
// attempt to register
$reg_result = register($username, $email, $mimetype, $passwd);
Here is the register() function. The error seems to begin here.
function register($username, $email, $mimetype, $password)
// register new person with db
// return true or error message
{
// connect to db
$conn = db_connect();
if (!$conn)
return 'Could not connect to database server - please try later.';
// check if username is unique
$result = mysql_query("select from user where username='$username'");
//bugcheck
echo "select from user where username='".$username."'</br>";
echo mysql_num_rows($result);
if (!$result)
return 'Could not execute query';
if (mysql_num_rows($result)>0)
return 'That username is taken - go back and choose another one.';
Here is the db_connect() function:
function db_connect()
{
$result = mysql_pconnect('localhost', 'reg_user', 'password');
if (!$result)
return false;
if (!mysql_select_db('register'))
return false;
return $result;
}
There doesnt seem to be a problem connecting to db.
Please, please help me out. Ive been trying to solve it for days without any luck.
Thanks for your time and help.
Kevin.