Code: Select all
// if ok, put in db
$result = $conn->query(
"insert into user values
('$username', sha1('$password'), '$email')");
if (!$result)
{
echo 'Could not register you in database - please try again later.';
}
return true;
}
function login($username, $password)
// check username and password with db
// if yes, return true
// else throw exception
{
// connect to db
$conn = db_connect();
// check if username is unique
$result = $conn->query("select * from user
where username='$username'
and passwd = sha1('$password')");
if (!$result)
echo "Could not log you in.";
if ($result->num_rows>0)
return true;
else
echo "Could not log you in.";
}This is the first part of a code I'm having problems with
its line 24 and 42-44 which is this:
Code: Select all
$result = $conn->query(
"insert_into_user_values
('$username', sha1('$password'), '$email')");and
Code: Select all
$result = $conn->query("select * from user
where username='$username'
and passwd = sha1('$password')");Parse error: parse error, unexpected T_STRING in /home/httpd/vhosts/tkdfc.hopto.org/httpdocs/user_auth_fns.php on line 24
Please help!
Thanks

