LemonInflux Posted October 4, 2007 Author Share Posted October 4, 2007 eh? Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-361851 Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 eh? Â Does this meen you don't understand something? What? Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-361853 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 Yes, it means I don't understand what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362588 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 this is going to be a long conversation. Â Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362613 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 I just want to know what's wrong with mine, not what I could be doing :\ Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362631 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 looks like you have a function defined. does it get called anywhere? Â You dont echo the messages within the function, nor return the $message variable for display outside of the function. Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362633 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 Why not? Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362647 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 we're telling you what's wrong. Â 1. you have a function called login. do you ever call it from anywhere else in your code? Â 2. inside your function, you set a value for $message but it is never echoed anywhere or provided outside of the function. Â essentially you have a function that is never called that wouldn't do anything if it was called. Â Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362650 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 The user enters a username and password, and submits it. On submit, the function is called. Then, the messages are echoed on the page. Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362674 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 excellent. can we see the updated code where this happens? Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362711 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 auth.inc.php (complete w/ notes):  <?php session_start(); // authenticate username/password against /data/users.db.php // returns: -1 if user does not exist //     0 if user exists but password is incorrect //     1 if username and password are correct function auth($user, $pass){ $result = -1; if((trim($user) != "") && (trim($pass) != "")){ $sql = 'SELECT * FROM `members`'; $sqlresult = mysql_query($sql); while ($row = mysql_fetch_assoc($sqlresult)) {  // if username matches  // test password  if($row['username'] == $user){   // if match, user/pass combination is correct  // return 1  if($row['password'] == $pass){   $result = 1;   break;  }else{   // otherwise return 0   $result = 0;   break;  }  } } } // return value return $result; } // Check if Sessions have exist or else see if any var's are posted if(!isset($_SESSION["SESSION_UNAME"]) && !isset($_SESSION["SESSION_UPASS"])){ $f_user = $_POST['f_user']; $f_pass = sha1($_POST['f_pass']); }else{ $f_user = $_SESSION["SESSION_UNAME"]; $f_pass = $_SESSION["SESSION_UPASS"]; } if($_GET['logout'] == "true"){ $f_user = ""; $f_pass = ""; session_unset(); session_destroy(); header("Location: ?"); } ?>  Then, where it's called.  <?php include('config.inc.php'); include('db_fns.php'); db_connect(); include('auth.inc.php'); if(auth($f_user, $f_pass) == 1){ $_SESSION['SESSION_UNAME'] = $f_user; $_SESSION['SESSION_UPASS'] = $f_pass; } ?>  Then, if I want the message, I use 'if(isset($message)){echo $message; }' Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362718 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 there is no $message in the code you posted.??  Also it looks like there are too many braces, }  you may want to consider indenting your code so mistakes jump out. Your return is outside of the function:  function auth($user, $pass){  $result = -1; if((trim($user) != "") && (trim($pass) != "")){ $sql = 'SELECT * FROM `members`'; $sqlresult = mysql_query($sql); while ($row = mysql_fetch_assoc($sqlresult)) { // if username matches // test password if($row['username'] == $user){    // if match, user/pass combination is correct // return 1 if($row['password'] == $pass){ $result = 1; break; } else { // otherwise return 0 $result = 0; break; } }  } } // return value return $result; // RETURN IS OUTSIDE OF THE FUNCTION }  this shouldn't even compile. no errors shown? Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362725 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 Used that, still no luck. To try it out, go to http://reflexprojects.net/forumbuild/index.php - username: tom, password: test Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362733 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 i was pointing out the mistake, not correcting it. as i stated, that code you posted shouldn't even compile. one of the problems is that your return is OUTSIDE THE FUNCTION. Â Â Â Â Â Â } } } // FUNCTION IS CLOSE HERE, BUT.... // return value return $result; // RETURN IS OUTSIDE OF THE FUNCTION } Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362736 Share on other sites More sharing options...
LemonInflux Posted October 5, 2007 Author Share Posted October 5, 2007 Put it in, still no luck. Quote Link to comment https://forums.phpfreaks.com/topic/71393-wheres-the-error/page/3/#findComment-362748 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.