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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.