Jump to content

Login Not Working


podja

Recommended Posts

havnt done any PHP in a while, but I've decided to start a new project. I am already getting really annoyed with this script, I cant see why it wont work! Could you take a look and give me some pointers.

 

Heres the PHP part. (sv-includes/dologin.php)

<?php

    if(isset($_POST['dologin'])) {

        $user = $_POST['dologin_user'];
        
        $pass = $_POST['dologin_pass'];
                
        include("connect.php");
    
        $query = mysql_query("SELECT * FROM `members` WHERE `user` = '$user' AND `pass` = '$pass'");
        $count = mysql_num_rows($query);
            
        if($count>0) {
            
            echo "Logged In";
                
        } else {
            
            echo "Wrong Username or Password";
                
        }
    
    }
    
    
?> 

 

 

Heres the HTML part (index.php)

<form id="form1" name="form1" method="post" action="sv-includes/dologin.php">  <p>Username: <input name="dologin_user" type="text" id="dologin_user" /> </p>  <p>Password: <input name="dologin_pass" type="text" id="dologin_pass" />  <input name="dologin" type="submit" id="dologin" value="Submit" />  </p> </form>

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/46265-login-not-working/
Share on other sites

What boo stated is incorrect, the dologin is right.

 

Is the password that is stored in the DB md5 hashed? if so you need to hash that password. If not that is a major security risk and should probably be hashed some way or form.

 

<?php

    if(isset($_POST['dologin'])) {

        $user = $_POST['dologin_user'];
        
        $pass = $_POST['dologin_pass'];
                
        include("connect.php");
    
        $query = mysql_query("SELECT * FROM `members` WHERE `user` = '$user' AND `pass` = '$pass'") OR DIE(mysql_error()); // add the or die make sure the query is right.
        $count = mysql_num_rows($query);
            
        if($count>0) {
            
            echo "Logged In";
                
        } else {
            
            echo "Wrong Username or Password";
                
        }
    
    }
    
    
?> 

Link to comment
https://forums.phpfreaks.com/topic/46265-login-not-working/#findComment-225078
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.