Jump to content

Login Function Problem


wickedXxxxlegox

Recommended Posts

Hi guys,

 

I made a login, and I have a function that is not working. I'll give you all of the parts to it.

 

Function:

 

 

}

function user_exists($username) {
$username = sanitize($username);
$query = mysql_query("SELECT COUNT (`id`) FROM `members` WHERE `username` = '$username'")
return (mysql_result($query, 0) == 1) ? true : false;
}

 

login page:

if(empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];



if(empty($username) === true || empty($password) === true) {
$errors[] = 'Please enter a username and password.';
}
else if(user_exists($username) === false) {
$errors[] = 'We can\'t find that username. Have you <a href="register.php">register</a>ed?';
}
else if(user_active($username) === false) {
$errors[] = 'You have not activated your account. Check your Email!';
} else {
$login = login($username, $password);
if($login === false) {
$errors[] = 'That username/password combination is incorrect.';
} else {
echo 'You are now logged in. Please wait for the page to refresh or click <a href="home.php">here</a>.';
$_SESSION['id'] = $login;
echo '<meta http-equiv="refresh" content="0;url=home.php">';
exit();
}
}

print_r($errors);
}
?>

 

Error: Fatal error: Call user_exists() in /home/a1922355/public_html/login.php on line 13

Edited by wickedXxxxlegox
Link to comment
Share on other sites

I'll give you all of the parts to it.

 

All the relevant parts would be ALL the code (less any database credentials), from the start of login.php up through the line where the error is occurring at. That would include (pun intended) your code showing how you are including the various files, along with showing the php tags in your file(s).

 

You either are including using a URL (doesn't include php code, only the output you send), don't have full php tags, or have multiple files at different paths, some with and some without that function definition in it.

Link to comment
Share on other sites

You're missing a semi-colon in your user_exists() function.

 

function user_exists($username) {
$username = sanitize($username);
$query = mysql_query("SELECT COUNT (`id`) FROM `members` WHERE `username` = '$username'"); //<-- added semi-colon
return (mysql_result($query, 0) == 1) ? true : false;
}

 

Not sure if this fixes the error though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.