Easy Script change for E-Gold $_POST $_SESSIONS

Discussion in 'PHP' started by jimm11, Apr 5, 2008.

  1. #1
    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.
     
    jimm11, Apr 5, 2008 IP
  2. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #2
    If it's a single file please post the script here
     
    Dagon, Apr 5, 2008 IP
  3. jimm11

    jimm11 Well-Known Member

    Messages:
    132
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    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
     
    jimm11, Apr 5, 2008 IP
  4. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #4
    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.
     
    Dagon, Apr 5, 2008 IP
  5. Dagon

    Dagon Active Member

    Messages:
    122
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #5
    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)
     
    Dagon, Apr 5, 2008 IP
  6. jimm11

    jimm11 Well-Known Member

    Messages:
    132
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #6
    I sent you some E-Gold :D.

    Thanks for your help.
     
    jimm11, Apr 6, 2008 IP