Seemingly simple user login in PHP killing me...

  1. #1
    sadnbj is offline Newbie

    Angry Seemingly simple user login in PHP killing me...

    Hello,
    Can anyone help?
    I have been working on this for hours and days and can't find the error. Admittedly I am new PHP.

    Here is the code...
    It is giving me the error
    Parse error: parse error, unexpected $ in /home/admin/domains/nmanet.org/public_html/nmacms/core/core.functions.php(570) : eval()'d code on line 330
    THere isn't a line 330/ I think it has something to do with the Seission variable.


    <?php
    session_start();

    if(!empty($_SESSION['userID'])) {

    $msg="<strong><span class=MainContent><font size=2>You are already logged in! <br> Use the menu on the left to go to your desired Member Only location.</font></span></strong>";

    }
    else
    {

    //if the session is empty but te user is attempting login...
    // if(empty($_SESSION['userID'])) {

    if(!empty($_POST['txtUSERNAME'])){


    $conn = mysql_connect("localhost","admin","mABjXhy1") or die(mysql_error());
    mysql_select_db("admin_nma",$conn);


    $user_name = $_POST['txtUSERNAME'];
    $password = $_POST['txtPASSWORD'];

    $user_name = stripslashes($user_name);
    $password = stripslashes($password);


    //checks to see if user is already a member
    $sql_spw_check = mysql_query("SELECT Session FROM tblRealTimeJoinData WHERE username='$user_name' AND password='$password'",$conn);
    $result = mysql_result($sql_upw_check, 0);
    if(!$result){
    die('Could not query:' . mysql_error());
    }
    echo mysql_result($result,0);
    //$userID=mysql_result($result,0);

    $upw_check = mysql_num_rows($sql_upw_check) or die(mysql_error());

    echo $sql_upw_check;
    if($upw_check > 0) {

    //$_SESSION['SessionID'] = $sessionID;
    $msg = "<strong><span class=MainContent>You are now logged in!</span>";
    }
    else
    {

    $msg = "<strong><span class=MainContent><font=red>That Username and password is not found in our database.Please try again.</font></span>";
    unset($username);
    unset($password);
    }

    } //username not empty
    //session empty
    ?>


  2. #2
    HappyBeaver is offline Bea*ering Away!
    Are you trying to install this for a website? A lot of installation errors are due to not having the right privileges on the files server side. Make sure you have the correct CHMOD attributes assigned to each file/folder on your webserver

    Also, check that you have the correct PHP version running on your webserver in relation to what the code was written for.

    It could have been a corrupt file... have you contacted the person that wrote the code? Perhaps they have a FAQ contact point?
    Last edited by HappyBeaver; 06-04-2006 at 05:46 PM.

  3. #3
    DevilsAdvocate is offline Elite Member
    Tackle the Web with $5.99 .COM's from Go Daddy!
    If I give you a tip can I have a piece of your salary (I imagine the NMA pay reasonably well).

    Tip of the day; make sure you don't show the world your database login details... Otherwise you could find someone having it away with all your data (not me, of course, I wouldn't do such a thing, would I?)

    Quote Originally Posted by sadnbj
    <?php
    session_start();

    if(!empty($_SESSION['userID'])) {

    $msg="<strong><span class=MainContent><font size=2>You are already logged in! <br> Use the menu on the left to go to your desired Member Only location.</font></span></strong>";

    }
    else
    {

    //if the session is empty but te user is attempting login...
    // if(empty($_SESSION['userID'])) {

    if(!empty($_POST['txtUSERNAME'])){


    $conn = mysql_connect("localhost","admin","mABjXhy1") or die(mysql_error());
    mysql_select_db("admin_nma",$conn);


    $user_name = $_POST['txtUSERNAME'];
    $password = $_POST['txtPASSWORD'];

    $user_name = stripslashes($user_name);
    $password = stripslashes($password);


    //checks to see if user is already a member
    $sql_spw_check = mysql_query("SELECT Session FROM tblRealTimeJoinData WHERE username='$user_name' AND password='$password'",$conn);
    $result = mysql_result($sql_upw_check, 0);
    if(!$result){
    die('Could not query:' . mysql_error());
    }
    echo mysql_result($result,0);
    //$userID=mysql_result($result,0);

    $upw_check = mysql_num_rows($sql_upw_check) or die(mysql_error());

    echo $sql_upw_check;
    if($upw_check > 0) {

    //$_SESSION['SessionID'] = $sessionID;
    $msg = "<strong><span class=MainContent>You are now logged in!</span>";
    }
    else
    {

    $msg = "<strong><span class=MainContent><font=red>That Username and password is not found in our database.Please try again.</font></span>";
    unset($username);
    unset($password);
    }

    } //username not empty
    //session empty
    ?>
    Adieu, and thanks for the info.

+ Reply to Thread