[code] // 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.";
}[/code]
This is the first part of a code I\'m having problems with
its line 24 and 42-44 which is this:
[code]
$result = $conn->query(
"insert_into_user_values
(\'$username\', sha1(\'$password\'), \'$email\')");[/code]
and
[code] $result = $conn->query("select * from user
where username=\'$username\'
and passwd = sha1(\'$password\')");[/code]
I really don\'t know enough PHP to beable to fix this. I\'m sure it can\'t be anything that drastic, but I don\'t know much to be able to fix it. The exact error I\'m getting is this:
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
Code help
Moderators: Moderator, Global Moderator
Code help
Maybe change those 2 codes to this?:
[code]$result = $conn->query("insert_into_user_values(\'$username\', sha1(\'$password\'), \'$email\')");[/code]
and
[code]$result = $conn->query("select * from user where username=\'$username\' and passwd = sha1(\'$password\')");[/code]
[code]$result = $conn->query("insert_into_user_values(\'$username\', sha1(\'$password\'), \'$email\')");[/code]
and
[code]$result = $conn->query("select * from user where username=\'$username\' and passwd = sha1(\'$password\')");[/code]
[align=center]

“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
[/align]

“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
[/align]
