Jump to content

Recommended Posts

Can someone please tell me if this is secure. Someone keeps logging into my admin account...

 

<?php

session_start();
if ($_POST['username'] == "" || $_POST['password'] == "")
{
die("<h3>Error</h3>
You did not fill in the login form!<br>
<a href=login.php>> Back</a>");
}
include "mysql.php";
global $c;
$uq=mysql_query("SELECT userid FROM users WHERE login_name='{$_POST['username']}' AND `userpass`='{$_POST['password']}'",$c) or die(mysql_error());
if (mysql_num_rows($uq)==0)
{
die("<h3> Error</h3>
Invalid username or password!<br>
<a href=login.php>> Back</a>");
}
else
{
$_SESSION['loggedin']=1;
$mem=mysql_fetch_array($uq);
$_SESSION['userid']=$mem['userid'];
header("Location: loggedin.php");
}

?>

Link to comment
https://forums.phpfreaks.com/topic/147651-secure-login/
Share on other sites

The only thing I can see is that it is prone to SQL injection, and your password is textual and not hashed or encrypted.

 

If magic_quotes is on that may protect you to a point, but you should really turn it off and use mysql_real_escape_string on data before testing them against a database.

 

Also make sure that you always call $_SESSION['loggedin'] and not just $loggedin (given that register_globals is on which it should not be).

 

Other than that check your password if it is very weak (something like 'password') I would suggest beefing it up.

Link to comment
https://forums.phpfreaks.com/topic/147651-secure-login/#findComment-775114
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.