Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool ?!Username Help!?

    PHP Code:
    <? mysql_connect'Localhost''xxx''xxx' ); 
    mysql_select_db'xxx' );  ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <title>Main Menu</title> 
    <style type="text/css"> 
    html, body { 
    margin:0; 
    padding:0; 
    background:#000; 
    color:#FFF; 

    .eric { 
        height: 400px; 
        width: 200px; 
        border: 3px solid red; 
        background: #fff; 
        color:#FFF; 
        float:left; 

    .rawli { 
        height: 400px; 
        width: 200px; 
        border: 3px solid red; 
        background: #fff; 
        float: right; 

    </style> 
    </head> 
    <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center>  
    <center><h3><? print"$user[username] (#$user[id])"?></h3></center>
    <body> 
    <div class="eric"> 
    <a href="turntrick.php">Turn Tricks</a> 
    <br><br> 
    <a href=">forums.php">Forums</a> 
    <br><br> 
    <a href="getturns.php">Buy Turns</a> 
    <br><br> 
    <a href="attackrank.php">Attack Ranks</a> 
    <br><br> 
    <a href="cityr.php">City Ranks</a> 
    </div> 
    <div class="rawli"> 
    <a href="naranks.php">National Ranks</a> 
    <br><br> 
    <a href="store.php">Corner Store</a> 
    <br><br> 
    <a href="faqs.html">Faqs</a> 
    <br><br> 
    <a href="http://www.thugkillin.urlshort.com">LogOut</a> 
    </div> 
    </body> 
    </html>
    that is my base.php, and what im trying to do is get the username that i loged in with shows up in the browser....ex. Rawlijr(#1)


    and im not sure if this will work or not?And what will i have to add to make it work if anybody knows?

    PHP Code:
    <? print"$user[username] (#$user[id])"?>


    Cheers,
    Rawli
    Last edited by RawliJr; 06-26-2006 at 08:09 PM.
    Rawli

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Impossible to answer without more info. We don't know how your login system is setup. All your code shows is you connecting to the database and displaying an image.

    ~Phil~

  • #3
    Regular Coder
    Join Date
    May 2006
    Location
    Canada
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, ill post the login system...

    PHP Code:
    <? ob_start(); ?> 
    <html> 
    <head> 
    <title>ThugKillin</title> 
    </head> 
    <body> 
    <center><img src="/images/THUGKILLIN.jpg" border="0" width="444" /></a></center> 
    <body bgcolor="#000" text="white"> 
    <center> 
    <? 

    if( empty($_POST['username']) || empty($_POST['password']) ) 

        echo 
    'Invalid username/password try again'

        exit(); 


    if( !
    preg_match('/^[a-z][a-z0-9_-]{3,31}$/i'$_POST['username']) || (strlen($_POST['password']) < 6) ) 


        echo 
    'Invalid username/password try again!'
        exit(); 


    mysql_connect'Localhost''xxx''xxx' ); 
    mysql_select_db'xxx' ); 

    $result mysql_query"SELECT id FROM users WHERE username='{$_POST['username']}' AND password='{$_POST['password']}'" ); 
    $user mysql_fetch_assoc$result ); 
    mysql_free_result$result ); 

    mysql_close(); 

    if( empty(
    $user) ) 

        echo 
    'Invalid username/password try again!'
        exit(); 

    header'Location: http://thugkillin.urlshort.com/base.php' ); 
    $_SESSION['user_id'] = $user['id']; 
    ?> 
    </center> 
    </body> 
    </html>
    Rawli


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •