Hi, I need someone to change a script I have using "globals on" to the php 5 version with globals off. Should be easy enough for somebody here. It's just an old recipe script from easy site networks which is a free script. I just need to know how much you would charge I will pay using E-Gold after the work is complete. Thanks.
Hi thanks for replying. Here's the code for a page of the script the sessions are logging out after this page because of globals not being on. I would like to update the code so it will will work with globals off. I know to change the login with $_POST[login] and $_POST[password]. But keeping the sessions from page to page is the problem. <?php $sql = "select * from users where login = '$login' and password = '$password'"; $result = mysql_query($sql ,$db); if ($myrow = mysql_fetch_array($result)) { do { $uid = $myrow["userid"]; $uname = $myrow["login"]; } while ($myrow = mysql_fetch_array($result)); $loggedin = true; $upwd = $password; $msg = "Welcome $uname, you are now logged in. <a href=index.php>Click here</a> to return to the front page."; } else { $loggedin = false; $upwd = ""; $uid = ""; $uname = ""; $msg = "Sorry, that login and password is not valid. Click back on your browser to try sgain. If you have forgotten your password <a href=forgot.php>click here</a>. If you are a new user you will need to <a href=newuser.php>create a new login</a>"; } session_register("loggedin"); session_register("upwd"); session_register("uid"); session_register("uname"); ?> <TD align="left" valign="top" bgcolor="#DEDDDC"> <table width="100%" border="0" cellspacing="5" cellpadding="5"> <tr> <td valign="top"> <TABLE width=100% cellpadding=5 cellspacing=0 border=0> <tr><td width=500 align=center> <table cellpadding=1 cellspacing=1 border=0><tr><td bgcolor=#000000 width=500 height=20 valign=center align=center> <table cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=#cccccc width=498 height=18 valign=center align=left> <font face="Arial, Helvetica, sans-serif" size="3"><b>Login</b></font> </td></tr></table> </td></tr></table> </td></tr> <TR> <TD valign=top> <FONT SIZE=2> <center> <br><font size=2 face='Arial, Helvetica, sans-serif'><?php printf($msg); ?></font> </center> </FONT> </TD> </TR> </TABLE> </td> </tr> </table> </TD> Anyway thanks for looking
Here is the modified source: <?php session_start(); $sql = "select * from users where login = '$login' and password = '$password'"; $result = mysql_query($sql ,$db); if ($myrow = mysql_fetch_array($result)) { do { $uid = $myrow["userid"]; $uname = $myrow["login"]; } while ($myrow = mysql_fetch_array($result)); $loggedin = true; $upwd = $password; $msg = "Welcome $uname, you are now logged in. <a href=index.php>Click here</a> to return to the front page."; } else { $loggedin = false; $upwd = ""; $uid = ""; $uname = ""; $msg = "Sorry, that login and password is not valid. Click back on your browser to try sgain. If you have forgotten your password <a href=forgot.php>click here</a>. If you are a new user you will need to <a href=newuser.php>create a new login</a>"; } $_SESSION['loggedin'] = $loggedin; $_SESSION['upwd'] = $upwd; $_SESSION['uid'] = $uid; $_SESSION['uname'] = $uname; ?> You can access the variables with $_SESSION['varname'] once they are saved in a session like in the example above.
Or place this code on top of the other pages... <?php session_start(); foreach ($_SESSION as $key => $value) $$key = $value; ?> (haven't tested it but i guess it should work)