Jump to content

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

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.