Jump to content

mysql php login


pjheliking

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.