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
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Specific User Login Redirect

    PLEASE HELP ME.
    I do not know much about coding.. I have created a database (mysql) I have a login and registration page. I need to make it so a user gets directed to their own page when they login..
    Example:

    If username is Dizzy123 then go to

    www.mysite.com/members/Dizzy123/

    I don't even know where to start.. Can some one give me some advice.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well that pretty easy. In the code for checking the users login you can simply use a redirect header.


    After the login has been verified you can grab the username either from the form they submitted or from the query you did to validate the login.

    something like
    $username = $_POST['username'];

    or like

    $username = $row['username'];

    Obviously the exact coding will depend on what your coding is.

    And then all you need is to redirect them with a redirect header like so.

    header("Location: /members/" . $username);

    you can use either a relative path something like above or use the full URL.

    header("Location: http://www.mysite.com/members/" . $username);
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    Create a session on the login page called username that matches the username field in your form. Put something like this on the logged in correctly page...

    PHP Code:
    <?php
    $user 
    $_SESSION['username'];

       
    header("location: /$user/");
     
    ?>


  •  

    Posting Permissions

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