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 6 of 6

Thread: Profile Linking

  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Profile Linking

    I apologize if this has been asked. I did search the forum first. First off I'm new to PHP but I'm getting a hang on it I think.

    I'm trying to create a way for users of my site (which is in the works) to be able to give links to their profiles to people like this

    www.mysite.com/username

    Kinda like myspace does. However I don't want to create a new directory for EVERY user because I'd still like them all to use

    www.mysite.com/profile.php

    instead of having to create a new one for everyone, because that obviously defeats the purpose of creating a data driven site anyway, right???

    Anyone know how to do this?

    Thanks
    Tim

  • #2
    New Coder
    Join Date
    Jul 2009
    Location
    UK
    Posts
    89
    Thanks
    5
    Thanked 11 Times in 11 Posts
    You could use the get method.

    www.mysite.com/profile.php?user=jswany

    then use the following to get thier data
    PHP Code:
    $user mysql_real_escape_string($_GET['user']);

    // then use sql to retreive thier data.
    $sql "SELECT * FROM users WHERE user='$user'";
    $get_details mysql_query($sql) or die (mysql_error()); 
    just an idea

  • Users who have thanked jswany for this post:

    timcalvin (08-07-2009)

  • #3
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hey jswanty,

    Thanks for the tip. That's how I'm assuming I'm going to be doing it, I just thought it would be cool and look better if I could leave out everything except the username.

  • #4
    New Coder
    Join Date
    Jul 2009
    Location
    UK
    Posts
    89
    Thanks
    5
    Thanked 11 Times in 11 Posts
    well you could do
    www.mysite.com/?user=jswany

    and the on the index page have
    PHP Code:
    if(isset($_GET['user'])) {
    $user mysql_real_escape_string($_GET['user']);
    header("location:profile.php?user=$user");
    exit;

    then use the same code as before on your profile page
    PHP Code:
    $user mysql_real_escape_string($_GET['user']);

    // then use sql to retreive thier data.
    $sql "SELECT * FROM users WHERE user='$user'";
    $get_details mysql_query($sql) or die (mysql_error()); 
    but then that isn't much better

  • #5
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Just use mod rewrite.. In your .htaccess put something like

    Code:
    RewriteEngine On
    
    RewriteRule ^([a-zA-z]+)$ profile.php?user=$1
    Then site.com/username is the same as site.com/profile.php?user=username
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #6
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Cool... I definitely like that better... it's a step in the right direction! Good idea.


  •  

    Tags for this Thread

    Posting Permissions

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