Jump to content

register_globals off solution required


schandhok

Recommended Posts

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();
[color=red]$login=trim($_POST["login"]);
$password=trim($_POST["password"]);[/color]

$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 >>>>>>>>>>>>>>>>

[color=red]<?php
if($user=@$GLOBALS['user']){
?><h3>Welcome <?
echo $user["login"];[/color]
?>
&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>
<?
}
?>

[font=Verdana]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?[/font]

Please Help

Thank You
Link to comment
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.