bofett Posted May 4, 2009 Share Posted May 4, 2009 I am trying to figure out how to keep my program working and turn off register_globals. From what I have been reading it seems to be a simple change but I cant seem to get it to work. for example... //I think I have to change something like this session_register("myuid"); //to $_session["myuid"] = $myuid; //then call $_session["myuid"] //instead of $myuid //right? Anyway, here is the code I am using now with register_globals=on (session_start() is being callid in common.php) include("include/common.php"); if( $_POST['username'] && $_POST['password'] ){ $failed = 1; $username = $_POST['username']; $password = $_POST['password']; $query = "SELECT * FROM users WHERE username='$username' AND password='$password'"; # echo $query; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); if ( ($result) && (mysql_num_rows($result) > 0) ){ $row = mysql_fetch_object($result); $adlogin = $row->username; $myname = $row->username; $adpassword = $row->password; $myuid = $row->uid; # echo $adlogin." ----".$adpassword."<br>"; if ( ($username != $adlogin) || ($password != $adpassword) ){ $failed = 1; }else{ $failed = 0; $loggedin = 1; session_register("loggedin"); session_register("myuid"); session_register("myname"); } }else{ $failed = 1; $loginerror = "<font color='#FF0000'>Username or password incorrect.</font>"; } } Thanks for all of the help! Link to comment https://forums.phpfreaks.com/topic/156723-solved-session_register-and-register_globals/ Share on other sites More sharing options...
seaweed Posted May 4, 2009 Share Posted May 4, 2009 session_register is depreciated... http://us2.php.net/session_register Link to comment https://forums.phpfreaks.com/topic/156723-solved-session_register-and-register_globals/#findComment-825428 Share on other sites More sharing options...
wildteen88 Posted May 4, 2009 Share Posted May 4, 2009 session_register should only be used when register_globals is enabled. When its disabled you use the $_SESSION superglobal variable for reading/writing to your session. <?php // when dealing with session always call session_start() session_start(); // assign new session variables $_SESSION['my_var1'] = 'new value'; $_SESSION['my_var2'] = 'another value'; ?> Now to retrieve your session variables you use. <?php // again make sure you call session_start() when using $_SESSION variables session_start(); // assign new session variables echo 'SESSION Vars:<br />'; echo 'my_var1 = "'$_SESSION['my_var1'] . '"<br />'; echo 'my_var2 = "'$_SESSION['my_var2'] . '"<br />'; ?> Do note the $_SESSION supergloabl is case-sensitive just like $_POST, $_GET and $_COOKIE etc Link to comment https://forums.phpfreaks.com/topic/156723-solved-session_register-and-register_globals/#findComment-825467 Share on other sites More sharing options...
bofett Posted May 4, 2009 Author Share Posted May 4, 2009 Do note the $_SESSION supergloabl is case-sensitive just like $_POST, $_GET and $_COOKIE etc Thank you! That was my problem. Link to comment https://forums.phpfreaks.com/topic/156723-solved-session_register-and-register_globals/#findComment-825807 Share on other sites More sharing options...
bofett Posted May 4, 2009 Author Share Posted May 4, 2009 Exactly! session_register is depreciated... http://us2.php.net/session_register Link to comment https://forums.phpfreaks.com/topic/156723-solved-session_register-and-register_globals/#findComment-825808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.