wickedXxxxlegox Posted November 7, 2012 Share Posted November 7, 2012 (edited) 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 November 7, 2012 by wickedXxxxlegox Quote Link to comment Share on other sites More sharing options...
Jessica Posted November 7, 2012 Share Posted November 7, 2012 You have to include the file that has that function on your login page. Use require_once. Quote Link to comment Share on other sites More sharing options...
wickedXxxxlegox Posted November 7, 2012 Author Share Posted November 7, 2012 You have to include the file that has that function on your login page. Use require_once. Oops, forgot to tell you that. I have the file included on init.php and then init.php is required on login,php. Quote Link to comment Share on other sites More sharing options...
Jessica Posted November 7, 2012 Share Posted November 7, 2012 You changed your error message, now it doesn't make sense. That's not a valid error message. Based on your previous posts and behavior, I'm pretty sure you're a troll. If you truly want help, behave. Quote Link to comment Share on other sites More sharing options...
wickedXxxxlegox Posted November 7, 2012 Author Share Posted November 7, 2012 Whoops. I was trying to fix the text. Here it is: Fatal error: Call to undefined function user_exists() in /home/a1922355/public_html/login.php on line 13 Quote Link to comment Share on other sites More sharing options...
wickedXxxxlegox Posted November 7, 2012 Author Share Posted November 7, 2012 Dangit! Here: Fatal error: Call to undefined function user_exists in /home/a1922355/public_html/login.php on line 13 Quote Link to comment Share on other sites More sharing options...
wickedXxxxlegox Posted November 7, 2012 Author Share Posted November 7, 2012 Stupid text Quote Link to comment Share on other sites More sharing options...
White_Lily Posted November 7, 2012 Share Posted November 7, 2012 if it cant find the function then you probably haven't included the file properly. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 7, 2012 Share Posted November 7, 2012 Here's a readable version of your error (there's a remove format button, looks like an eraser) - Dangit! Here: Fatal error: Call to undefined function user_exists in /home/a1922355/public_html/login.php on line 13 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 7, 2012 Share Posted November 7, 2012 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. Quote Link to comment Share on other sites More sharing options...
krisw44 Posted November 7, 2012 Share Posted November 7, 2012 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.