Jump to content

[SOLVED] Login Security


vicodin

Recommended Posts

Hello im new to PHP and pretty much just a beginner programmer... I have created this script to protect some pages in my site. I know there are def a ton of security flaws but am i missing anything huge to where as even moderate hacker could exploit? I do have it where it takes out any type of script and html  from the user entered data. The pages im trying to protect are looking to see if the session['user'] is set and if its not it redirects back to the main page. Any type of feedback would be much appreciated. Thanks!

 

 

 

 

function checkauth($userid,$passid){

mysql_connect("*****", "******", "*******") or die(mysql_error());

mysql_select_db("********") or die(mysql_error());

$query = "SELECT * FROM *****";

$result = mysql_query($query) or die(mysql_error());

 

while ($row = mysql_fetch_array($result)){

if ($row['user'] == $userid && $row['password'] == $passid){

$_SESSION['user'] =$userid;

}

} }

checkauth($_POST['user'],$_POST['pass']);

Link to comment
https://forums.phpfreaks.com/topic/86827-solved-login-security/
Share on other sites

Personally... I think this might simplify things for you... Although, I would simply look further into the mysql_real_escape_string function.

 

mysql_connect('*****', '******', '*******') or die(mysql_error());
mysql_select_db('********') or die(mysql_error());

function checkauth($userid, $passid) {
        $userid = mysql_real_escape_string($userid);
        $password mysql_real_escape_string($userid);
        $user_found = mysql_result(mysql_query('SELECT count(0) FROM `users_table` WHERE `user` = "'.$userid.'" AND `password` = "'.$password.'"'), 0);

        if ($user_found) {
                $_SESSION['user'] = $userid;
        }
}
checkauth($_POST['user'], $_POST['pass']);

Link to comment
https://forums.phpfreaks.com/topic/86827-solved-login-security/#findComment-444214
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.