Hiya All,<br /><br />First time posting within the family forums in a long time (just got another domain after being away fer a bit)<br /><br />Anyway, lookin' for some help<br />Have a MySql Dbase with a Users table, to which of course holds user info - username and password<br />I have inserted the user info into the dbase with a config *.sql file.<br />The syntax I used was<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->insert into users(username, password, fullname, company, email, phone) values ('mwells', sha1('Te5t3r'), 'Mike Wells', 'EMT', '[email protected]', '847.123.1234');<!--c2--></div><!--ec2--><br /><br />Now the problem I am having is that, whenever I test authentication, it does not seem to pass and I get my "Failure" message (within the login.php file).<br />If I echo the $_REQUEST the info passed to the login script is correct. Any ideas on why I cannot get this to start my session??<br /><br /><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><b>login.php</b><!--sizec--></span><!--/sizec--><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />// Set up error reporting display<br />ini_set('display_errors', 1);<br />error_reporting(E_ALL);<br /><br /> include_once('cafs_fns.php');<br /><br />Â Â if ( (!isset($_REQUEST['username'])) || (!isset($_REQUEST['password'])) ) <br />Â Â {<br />Â Â Â Â echo 'You must enter your username and password to proceed';<br />Â Â Â Â exit;<br />Â Â }<br /><br />Â Â $username = $_REQUEST['username'];<br />Â Â $password = $_REQUEST['password'];<br /><br />if (login($username, $password)) <br />Â Â {<br />Â Â Â Â $_SESSION['auth_user'] = $username;<br />Â Â header('Location: '.$_SERVER['HTTP_REFERER']);<br />Â Â }<br />Â Â else <br />Â Â {<br />Â Â Â Â echo '<br>';<br />Â Â Â Â echo 'The credentials you have entered are incorrect<br>';<br />Â Â Â Â echo 'You must enter in a valid Username & Password to continue';<br />Â Â Â Â exit;<br />Â Â }<br />?><!--c2--></div><!--ec2--><br /><br />cafs_fns holds my connect to...script and an auth_fns script, to which also includes the login form itself<br /><br /><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><b>auth_fns.php</b><!--sizec--></span><!--/sizec--><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br /><br />// Set up error reporting display<br />ini_set('display_errors', 1);<br />error_reporting(E_ALL); <br />// Check username and password with db<br />Â Â function login($username, $password)<br />Â Â {<br />Â Â Â Â // connect to db<br />Â Â Â Â $handle = db_connect();<br />Â Â Â Â if (!$handle)<br />Â Â Â Â Â Â return 0;<br /><br />Â Â Â Â $result = mysql_query("select * from users,<br />Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â where username='$username' and<br />Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â password = sha1($password)", $handle);<br />Â Â Â Â if (!$result)<br />Â Â Â Â {<br />Â Â Â Â Â Â return 0;<br />Â Â Â Â }<br />Â Â Â Â if ($result->mysql_num_rows>0)<br />Â Â Â Â {<br />Â Â Â Â Â Â return 1;<br />Â Â Â Â }<br />Â Â Â Â else <br />Â Â Â Â {<br />Â Â Â Â Â Â return 0;<br />Â Â Â Â }<br />Â Â }<br /><br />Â Â function check_auth_user()<br />Â Â // see if somebody is logged in and notify them if not<br />Â Â {<br />Â Â Â Â global $_SESSION;<br />Â Â Â Â if (isset($_SESSION['auth_user']))<br />Â Â Â Â {<br />Â Â Â Â Â Â return true;<br />Â Â Â Â }<br />Â Â Â Â else<br />Â Â Â Â {<br />Â Â Â Â Â Â return false;<br />Â Â Â Â }<br />Â Â }<br />Â Â function login_form()<br />Â Â {<br />Â Â Â Â ?><br /><p> </p><br /><div id="global"><br />Â Â Â Â <form action='../cafs/admin/login.php' method='POST'><br />Â Â Â Â <table border=0><br />Â Â Â Â <tr><br />Â Â Â Â Â Â <td>Username</td><br />Â Â Â Â Â Â <td><input size='16' name='username'></td><br />Â Â Â Â </tr><br />Â Â Â Â <tr><br />Â Â Â Â Â Â <td>Password</td><br />Â Â Â Â Â Â <td><input size='16' type='password' name='password'></td><br />Â Â Â Â </tr><br />Â Â Â Â </table><br />Â Â Â Â <input type='submit' value='Log in'><br />Â Â Â Â </form><br /></div><br />Â Â Â Â <?php<br />Â Â }<br /><br />Â Â function check_permission($username, $file)<br />Â Â // check user has permission to act on this record <br />Â Â {<br />Â Â Â Â // connect to db<br />Â Â Â Â $handle = db_connect();<br />Â Â Â Â if (!$handle)<br />Â Â Â Â Â Â return 0;<br /><br />Â Â Â Â if(!$_SESSION['auth_user'])<br />Â Â Â Â Â Â return 0;<br /><br />Â Â Â Â $result = mysql_query("select * from user_permissions up, uploads d<br />Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â where up.user = '{$_SESSION['auth_user']}' and<br />Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up.company = d.client and<br />Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â d.id = $file<br />Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ", $handle);<br />Â Â Â Â if (!$result)<br />Â Â Â Â {<br />Â Â Â Â Â Â return 0;<br />Â Â Â Â }<br />Â Â Â Â if ($result->mysql_num_rows>0)<br />Â Â Â Â {<br />Â Â Â Â Â Â return 1;<br />Â Â Â Â }<br />Â Â Â Â else <br />Â Â Â Â {<br />Â Â Â Â Â Â return 0;<br />Â Â Â Â }<br />Â Â }<br />?><!--c2--></div><!--ec2--><br /><br />Thanks Ahead of Time All!!<!--content-->