Jump to content


Photo

register_globals off solution required


  • Please log in to reply
2 replies to this topic

#1 schandhok

schandhok
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 September 2006 - 10:01 PM

Hi
I had created a few php pages for my site which used register_globals as ON but the version of php has been updated at my server and i can no longer user register_globals to authenticate my login. Here is my code

form_login.php file contains this>>>
<form action="login.php" method=post>
<table border=0>
<tr>
<td>Login</td>
<td><input type=text name=login size=16></td>
</tr>
<tr>
<td>Password</td>
<td><input type=password name=password size=16></td>
</tr>
<tr>
<td><a href="prepare_registr.php">REGISTER</a></td>
<td><input type=submit value=" login "></td>

login.php contains this >>>>>
include "header.php";
#session_destroy();
unset($user);
#session_start();
$login=trim($_POST["login"]);
$password=trim($_POST["password"]);


$my_user='abcd';
$my_pass='1234';
$db=mysql_connect(localhost,$my_user,$my_pass);
mysql_select_db("blast",$db);

$rez = mysql_query("SELECT * FROM users WHERE u_login='$login' and u_password='$password'");
if(mysql_num_rows($rez)!=0){
list($user["id"],$user["login"],$user["password"],$user[ "mail"],$user["ldate"],$user["fname"],$user["lname"])=mysql_fetch_row($rez);
session_register("user");
$date=date("Y-m-d");
$id=$user["id"];
mysql_query("UPDATE users SET u_ldate='$date' WHERE u_id='$id'");
mysql_close($db);
header("location: index.php");
}
else{
include "header1.php";
include "left.php";
?><center> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&n bsp&nbsp&nbsp&nbsp User not found <a href='form_login.php'>Try again</a><?

ALL OF THIS WORKS BUT THE AUTHENTICATION AFTER LOGIN TAKES PLACE in header1.php which is this >>>>>>>>>>>>>>>>

<?php
if($user=@$GLOBALS['user']){
?><h3>Welcome <?
echo $user["login"];

?>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&n bsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&n bsp
<font color="red" ><a href=prepare_edit_user.php>Update Account</a>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&n bsp
<a href=logoff.php>LogOff</a></font></h3>
<?
}
?>

Since register_globals is off if($user=@$GLOBALS['user']){ never comes true and i cannot open my login pages...what other approach can i use to overcome this problem now?

Please Help

Thank You

#2 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 21 September 2006 - 10:16 PM

will u plz put your code in a code box its as ez as pressing a button or typeing [ code ] and [ /code ] without the spaces

#3 trillion

trillion
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 22 September 2006 - 03:03 AM

Look:

http://www.phpfreaks...registerglobals




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users