Thread: Select user

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20

    Select user


    hi there i have a login script that when i login it does not show the user's name..

    im guessing there would be an echo

    and i need to make a var with a sql query

    select from users where....

    can i get some help?
  2. #2
  3. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    show the relevant parts of code and explain in more detail what is going wrong if you would be so kind...
    10% gifted 90% puzzled
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    well code is big..but is is what part do you need?

    i found a login sytem on the net that does it.im trying to includ it in the login script i have now..
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    ferget that lol..

    ok here is the reference page of my form.

    PHP Code:
    <?

        setcookie 
    ("LMUSERNAME"$_POST['username']);
        
    setcookie ("LMPASSWORD"$_POST['password']);
     
          include_once (
    "auth_member.php");
        include_once (
    "admin/authconfig.php");
     
            
    $username =  $_POST['username'];
            
    $password =  $_POST['password'];

        
    $Auth = new auth();
        
    $detail $Auth->authenticate($username$password,$dbhost,$dbusername,$dbpass,$dbname);
        if ((
    $detail==0)||($detail['uname'] == $adminusername))
        {
        
    ?><HEAD>
            <SCRIPT language="JavaScript1.1">
            <!--
                location.replace("<? echo "$failure"?>");
            //-->
            </SCRIPT>
          </HEAD>
        <?
        
    }
        else 
        {
            
    $connection mysql_connect($dbhost$dbusername$dbpass);
            
    $SelectedDB mysql_select_db($dbname);
            
    $result mysql_query("select distinct welcome from authuser where uname='$username'");
            while(
    $row mysql_fetch_array($resultMYSQL_NUM)) {
            
    $v_welcome=$row[0];
            }
            if (
    $v_welcome=='1'){
            
    mysql_query("update authuser set welcome='0' where uname='$username'");
            
    mysql_close($connection);
            echo 
    "<meta http-equiv=\"refresh\" content=\"0; URL=$welcome\">";
            exit;        
            }
            else {
            
    mysql_close($connection);
            echo 
    "<meta http-equiv=\"refresh\" content=\"0; URL=$success\">";
            exit;        
            }

          }
    ?>
    could this help?
  8. #5
  9. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    The part of the code that is not doing as you expected. How can anyone help if they do not know what is going on?
    10% gifted 90% puzzled
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    everything is ok .i just want to add an echo username .
  12. #7
  13. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    So what is not doing what you expected?
    10% gifted 90% puzzled
  14. #8
  15. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    Add it where?!? In the code you show, nothing is being sent to screen, just redirecting to variables which I assume are other pages? to print user name to screen all you need to do is find the part of the code where you want it displayed and
    PHP Code:
    echo $username
    but I hope that is not what you needed to know because thats just silly.
    10% gifted 90% puzzled
  16. #9
  17. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    i get an undefined variable?were do i creat this variable?
  18. #10
  19. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    PHP Code:
    $username =  $_POST['username']; 
    is where you are setting that variable...I was just looking at your post history and I remember trying to help you in another thread once...Do you understand what the code you have actually does at all? I would suggest going through it all and commenting it heavily to try and gain understanding on what you are actually doing.
    10% gifted 90% puzzled
  20. #11
  21. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    sorry.but im ferly new.i understand but it's because adding to a already existing code messe's me up.

    sorry for newb question bro thx for your help.
  22. #12
  23. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    Originally Posted by techker
    sorry.but im ferly new.i understand but it's because adding to a already existing code messe's me up.
    sorry for newb question bro thx for your help.
    It's no problem, I am happy to help! Adding to existing code is tough, I know. That is why I suggested you go through all of it and comment so that you understand exactly what it is doing and why. I have learned a lot by doing that with any code I put to use, whether I wrote it or not. I meant no offense to you, I am probably more newb than you are, I didn't even know what html was a little more than a year ago! Repost when you find out what you need, and I will be happy to try and help again...
    10% gifted 90% puzzled
  24. #13
  25. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    ok so i define my variable
    PHP Code:
    <?php

      $username 
    =  $_POST['username']; 
      echo (
    "$username ");

    ?>
    then i
    PHP Code:
    <? echo $username ?>
    the place were i get screwed up is that im suposing that i have to put the variable in a page that processes the info?cause how does it now what user logs in?and it hase to fetch it in the database i supose.

    Comments on this post

    • bigSeth disagrees : you do not have to echo $username to define it.
  26. #14
  27. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    I commented you code a little to try and help you grasp what is going on...
    PHP Code:
        //here you are setting a cookie with the values passed from a
        //previous form. You are not checking if the values exist
        //though, so you may be setting empty cookies.
        setcookie ("LMUSERNAME", $_POST['username']);
        setcookie ("LMPASSWORD", $_POST['password']);
        //you are including these files...do you know what they are
        //and what they do?
        include_once ("auth_member.php");
        include_once ("admin/authconfig.php");
            //here is where you are setting username and password
            //you still havent checked if they exist though and 
            //if they do exist, what value do they have?
            $username =  $_POST['username'];
            $password =  $_POST['password'];
        //is auth() a pear package? do you know how to use it??? 
        $Auth = new auth();
        //now you are applying authenticate to your object auth()
        $detail = $Auth->authenticate($username, $password, $dbhost, $dbusername, $dbpass, $dbname);
        //now this says that if authenticate() returned 0 OR
        //if $detail['uname'] which is part of an array 
        //is equal to $adminusername  execute this html.
        //Do you know what $adminusername is?
        //I think this is to keep anyone from using the admin account
        if (($detail==0)||($detail['uname'] == $adminusername))
        {//$failure must be a "Sorry, try again." page
        ?><HEAD>
            <SCRIPT language="JavaScript1.1">
            <!--
                location.replace("<? echo "$failure"?>");
            //-->
            </SCRIPT>
          </HEAD>
        <?
        
    }
        else 
        {   
    //so know you know that $detail was successful 
            
    $connection mysql_connect($dbhost$dbusername$dbpass);
            
    $SelectedDB mysql_select_db($dbname);
            
    //now you are getting the contents of your column named
            //'welcome' from your table named 'authuser' where the
            //column named 'uname' is the same as $username
            //and why are you using DISTINCT???
            
    $result mysql_query("select distinct welcome from authuser where uname='$username'");
            
    //here you assume that there is only one result but 
            //you are using a while loop which is best for multiple
            //results. Is there one or more results? you should check! 
            
    while($row mysql_fetch_array($resultMYSQL_NUM)) {
              
    //even if there is more than one result, you are setting
              //$v_welcome to only use the first result.
              
    $v_welcome=$row[0];
            }
            
    //this is a problem because if your first query failed,
            //$v_welcome DOES NOT EXIST
            
    if ($v_welcome=='1'){
            
    //why do you set welcome back to 0 here?
            
    mysql_query("update authuser set welcome='0' where uname='$username'");
            
    mysql_close($connection);
            
    //this must send the user to happy land, meaning that
            //they got logged in. $welcome is PROBABLY the page 
            //where you want to echo $username. 
            //That is what this is all about right???
            
    echo "<meta http-equiv=\"refresh\" content=\"0; URL=$welcome\">";
            exit;        
            }
            
    //I see a problem here...if $v_welcome is equal to anything
            //but 1 you go to $success. does that mean you're logged in?
            
    else {
            
    mysql_close($connection);
            echo 
    "<meta http-equiv=\"refresh\" content=\"0; URL=$success\">";
            exit;        
            }

          }
    10% gifted 90% puzzled
  28. #15
  29. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    thx!

    i used
    Code:
    Username is available by using cookie:
    <?
    $USERNAME = $_COOKIE['LMUSERNAME'];
    ?>
    then i echo $username..

    lol

    by the way it there a way to make the echo look better?css it..

    Comments on this post

    • bigSeth disagrees : I hope nobody pays you to do this as your job...I only de-reped you as many points as you took to be clear on what you wanted.(-15)
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo