pjheliking Posted October 9, 2008 Share Posted October 9, 2008 any reason why this shouldnt work? <? session_start(); $username = $_POST['username']; $password = md5($_POST['password']); $url = $_SERVER['PHP_SELF']; $user = 'web177'; $pswd = 'asdsad'; $db = 'web177'; $conn = mysql_connect('192.168.1.6', $user, $pswd); mysql_select_db($db, $conn); $query = "SELECT * FROM login WHERE username = '$username' AND password = PASSWORD('$password')"; $result = mysql_query($query) or die("Unable to verify user because : " . mysql_error()); if(mysql_num_rows($result) == 1){ $_SESSION = true; session_register('username'); header("Location: divert.php?goto=".$url.""); }else{ header('Location: logfail.php') ; } ?> just it aint working and it has before its one i did earlier copied and pasted and changed the db details but thats not the problem hence i blocked that part out Link to comment https://forums.phpfreaks.com/topic/127688-mysql-php-login/ Share on other sites More sharing options...
revraz Posted October 9, 2008 Share Posted October 9, 2008 What isn't working? Is it not validating, is it not running, is it not redirecting on bad pw...? Chances are, it's not matching up the PW, if so then your DB isn't set like your other one. Check the field type and length of your PW field in the DB, since you use MD5 it should be VARCHAR and at least 40 length. Link to comment https://forums.phpfreaks.com/topic/127688-mysql-php-login/#findComment-660790 Share on other sites More sharing options...
aebstract Posted October 9, 2008 Share Posted October 9, 2008 Are you getting any errors or problems? Throw ini_set("display_errors","2"); ERROR_REPORTING(E_ALL); at the top and see if you get any errors Link to comment https://forums.phpfreaks.com/topic/127688-mysql-php-login/#findComment-660792 Share on other sites More sharing options...
pjheliking Posted October 9, 2008 Author Share Posted October 9, 2008 i was just about to do the report all but i thought ill hash the pass elsewhere set the variable and put the variable in the password bit it worked and im up and running. i didnt hash on my other project thats why thanks yall Link to comment https://forums.phpfreaks.com/topic/127688-mysql-php-login/#findComment-660883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.