Current location: Hot Scripts Forums » Programming Languages » PHP » Cannot login after host switched off register globals...


Cannot login after host switched off register globals...

Reply
  #1 (permalink)  
Old 08-29-07, 12:46 PM
AshleyQuick AshleyQuick is offline
Newbie Coder
 
Join Date: May 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Cannot login after host switched off register globals...

Can someone assist? Here's the login page:

PHP Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<html>
<head>
    <title></title>
</head>

<body>

<table>
    <form method="post" action="<? echo $PHP_SELF ?>?action=login">
    <tr>
        <td><b>Login name:</b><br>
        <input type="text" size="30" name="loginname"></td>
    </tr>
    <tr>
        <td><b>Password:</b><br>
        <input type="password" size="30" name="password"></td>
    </tr>
    <tr>
        <td><p><? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Do not link to this file!</p>"; } else { echo "<input class=send type=submit value=\"Login!\">"; } ?></p></td>
    </tr>
    </form>
</table>        

</body>
</html>
Here's protect.php

PHP Code:

<?


$user_passwords 
= array (
    
"demo" => "demo"
    
);

$logout_page "logout.php";

$login_page "login.php";

$invalidlogin_page "invalidlogin.php";


if (
$action == "logout")
{
    
Setcookie("logincookie[pwd]","",time() -86400);
    
Setcookie("logincookie[user]","",time() - 86400);
    include(
$logout_page);
    exit;
}
else if (
$action == "login")
{
    if ((
$loginname == "") || ($password == ""))
    {
        include(
$invalidlogin_page);
        exit;
    }
    else if (
strcmp($user_passwords[$loginname],$password) == 0)
    {
        
Setcookie("logincookie[pwd]",$password,time() + 86400);
        
Setcookie("logincookie[user]",$loginname,time() + 86400);
    }
    else
    {
        include(
$invalidlogin_page);
        exit;
    }
}
else
{
    if ((
$logincookie[pwd] == "") || ($logincookie[user] == ""))
    {
        include(
$login_page);
        exit;
    }
    else if (
strcmp($user_passwords[$logincookie[user]],$logincookie[pwd]) == 0)
    {
        
Setcookie("logincookie[pwd]",$logincookie[pwd],time() + 86400);
        
Setcookie("logincookie[user]",$logincookie[user],time() + 86400);
    }
    else
    {
        include(
$invalidlogin_page);
        exit;
    }
}
?>
Reply With Quote
  #2 (permalink)  
Old 08-29-07, 01:32 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
There are plenty of proper answers here:
http://www.codingforums.com/showthread.php?t=122487
__________________
The toxic ZCE
Reply With Quote
  #3 (permalink)  
Old 08-29-07, 01:34 PM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
Instead of $password and $loginname, use $_POST['password'] and $_POST['logginname']
__________________
Yep, it's a signature...
Reply With Quote
  #4 (permalink)  
Old 08-30-07, 03:37 PM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
Thats a very unsecure login script. I suggest look at hotscripts.com for a secure login script.

Register globals control the way POST, GET, COOKIE, GLOBALS get read.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to enable register globals through .htaccess file raji20 PHP 2 02-05-10 10:39 AM
Enable PHP with Register Globals Turned On Tutorial apthost Web Servers 1 03-29-07 04:41 AM
register globals off problem Bit Fick PHP 2 02-02-06 07:08 AM
Register Globals new2php PHP 1 10-15-05 09:50 AM
With register globals off... mejohn PHP 1 02-15-04 04:54 AM


All times are GMT -5. The time now is 06:09 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.