dazzclub Posted July 12, 2008 Share Posted July 12, 2008 hi guys, im using two functions that take care of the login/logout process...ive included the file using require_once.....when i visit the page the form is on it displays... Fatal error: Can't use function return value in write context in C:\wamp\www\darrensPAINT\loginB.php on line 21 The line 21 shows this code -------------- //check the login $list ($check, $data) = check_login($connection, $_POST['email'], $_POST['pass']); /*line 21*/ -------------- here is the loginB.php <?php //this page processess the login form //upon successful login, the user is redirected //two files included are neccessary //send NOTHING to the web browser prior to the setcookie() lines!. //check if the form has been submitted if(isset($_POST['submitted'])) { //for processing the login require_once('login_functions.inc.php'); //need the database connection require_once('includes/connection.php'); //check the login $list ($check, $data) = check_login($connection, $_POST['email'], $_POST['pass']); if($check) {//ok //set the cookies setcookie('user_id', $data['user_id']); setcookie('firstname', $data['firstname']; //redirect $url = absolute_url('loggedin.php'); header("location: $url"); exit(); //quit the script. }else{ //assign $data to $errors for error reporting //in the login_page.inc.php file. $errors = $data; } mysqli_close($connection);// close the database connection } //end of the main submit conditional //create the page include('login_page.inc.php'); ?> Any help to why this is happening would be great, cheers. Quote Link to comment https://forums.phpfreaks.com/topic/114470-solved-fatal-error-with-my-login-script/ Share on other sites More sharing options...
teynon Posted July 12, 2008 Share Posted July 12, 2008 Please show what the check_login code is Quote Link to comment https://forums.phpfreaks.com/topic/114470-solved-fatal-error-with-my-login-script/#findComment-588586 Share on other sites More sharing options...
dazzclub Posted July 12, 2008 Author Share Posted July 12, 2008 no probs here it is.. function check_login($connection, $email='', $pass='') { $errors = array();//initialize error array //validate the email address if(empty($email)) { $errors[] = 'You forgot to enter your email address.'; }else { $e = mysqli_real_escape($connection,trim($email)); } //validate the password if (empty($pass)) { $errors[] = 'You forgot to enter your password.'; }else{ $p = mysqli_real_escape_string($connection, trim($pass)); } if (empty($errors)) { // if everythings OK //retrieve the user_id, first_name for that email password combination $query = "SELECT user_id, first_name FROM users WHERE email= '$e' AND pass=SHA1('$p')"; $return = @mysqli_query($connection, $query); //Run the query //check the result: if(mysqli_num_rows($return) == 1) { //fetch the record: $row = mysqli_fetch_array($return, MYSQLI_ASSOC); //return true and record return array(true, $row); }else{ //not a match $errors[] = 'The email address and password entered do not match those on file.'; } }//end of empty($errors)IF //Return flase and the errors: return array(false, $errors); }//end of check _login() function cheers again. Quote Link to comment https://forums.phpfreaks.com/topic/114470-solved-fatal-error-with-my-login-script/#findComment-588589 Share on other sites More sharing options...
teynon Posted July 12, 2008 Share Posted July 12, 2008 Take the $ off of the list Quote Link to comment https://forums.phpfreaks.com/topic/114470-solved-fatal-error-with-my-login-script/#findComment-588595 Share on other sites More sharing options...
dazzclub Posted July 12, 2008 Author Share Posted July 12, 2008 Thats great....cant believe i didnt see that...i aslo noticed another error forgot a close a tag aswell....cheers mate...thanks for your help everyone *note to Darren Attention to detail otherwise you will get no where with your php!!!! Quote Link to comment https://forums.phpfreaks.com/topic/114470-solved-fatal-error-with-my-login-script/#findComment-588600 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.