kwandoa Posted April 19, 2013 Share Posted April 19, 2013 My form loads ok. login.php everything works like it should EXCEPT that when I submit the form with no password value I get the followoing error: Notice: Undefined variable: p in C:\EasyPHP\www\basicMySql\includes\login_functions.inc.php on line 41 But if i fill in a value, even a false one, the code works fine. could it be something to do with my isset()/empty() function? Link to comment Share on other sites More sharing options...
margaux Posted April 19, 2013 Share Posted April 19, 2013 could it be something to do with my isset()/empty() function? Probably - please show your code for login_functions.inc.php. Link to comment Share on other sites More sharing options...
kwandoa Posted April 21, 2013 Author Share Posted April 21, 2013 function redirect_user($page = 'index.php') { //define URL URL id http:// + host name + current directory $url = 'http://' .$_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF']); //remove any trailing slashes $url = rtrim($url, '/\\'); //add the page: $url .= '/' .$page; //add slashes that u removed //redirect the user header("Location:$url"); exit(); //quit script } //end of redirect_user() /* This function validates the form data(the email address and password). If both are present, the database is queried. The function requires a database connection.The function returns an array of information, including: a TRUE/FALSE variable indicating success - an array of either errors or the database result */ function check_login($dbc, $email = '', $pass = '') { $errors = array(); // initialize error array if(empty($email)) { //validate the email and password $errors[] = 'You forgot to enter your email address'; } else { $e = mysqli_real_escape_string($dbc, trim($email)); } if(empty($pass)) { $erros[] = 'You forgot to enter your password'; } else { $p = mysqli_real_escape_string($dbc, trim($pass)); } if (empty($errors)) { //if no erros occurred, run the databse query // Retrieve the user_id and first_name for that email/password combination: $q = "SELECT user_id, first_name FROM users WHERE email='$e' AND pass=SHA1('$p')"; $r = @mysqli_query($dbc, $q); //now check the results of the query: if(mysqli_num_rows($r) == 1) { //fetch the record $row = mysqli_fetch_array($r, MYSQLI_ASSOC); return array(true, $row); //return true and the record } else { //Not a match! $errors[] = 'The email and password entered do not matCH ThOse oN fiLe'; } } //End of empty($errors) IF //Return False and the errors: return array(false, $errors); } //End of check_login() function Link to comment Share on other sites More sharing options...
HartleySan Posted April 21, 2013 Share Posted April 21, 2013 What's line 41? Link to comment Share on other sites More sharing options...
Larry Posted April 21, 2013 Share Posted April 21, 2013 kwandoa, you really need to read the forum guidelines before you post again. You are consistently leaving out the most critical information, which makes trying to help impossible. Read them now, and abide them in the future. Link to comment Share on other sites More sharing options...
kwandoa Posted April 22, 2013 Author Share Posted April 22, 2013 ok, where would I find the guidelines? Link to comment Share on other sites More sharing options...
Antonio Conte Posted April 22, 2013 Share Posted April 22, 2013 http://www.larryullman.com/forums/index.php?app=forums&module=extras§ion=boardrules Link to comment Share on other sites More sharing options...
margaux Posted April 22, 2013 Share Posted April 22, 2013 guidelines, bottom right on every page. Please use code tags - its the icon on the edit toolbar that looks like <> and just post the relevant code. Also minor error in the line below $erros[] = 'You forgot to enter your password'; Link to comment Share on other sites More sharing options...
Recommended Posts