Jump to content

Covering up ?<get>=$ With any text


Anim8r

Recommended Posts

Hi my name is Aidan and I am new here.

 

Me and my friends are making a Social Network just for fun and to help us learn PHP in a more fun way. We are wanting to know if there is way to cover up the GET in the URL bar.

 

For example when your visiting a user's profile it will say in the URL bar: www.com/profile.php?id=<userid>

I also know that this is what Facebook do for their profile system.

However they also have a feature called 'usernames' which allows you to get facebook.com/<anything>

which replaces facebook.com/profile.php?id=<userid>

 

I was wondering how I would be able to implement this.

 

Many thanks,

Aidan

Link to comment
Share on other sites

The 'correct' way to do this is using mod_rewrite. This is an Apache directive, but other server will have an equivalent.

 

This is beyond the scope of this forum, but there's plenty out there. Googling it will return TONS of information.

Link to comment
Share on other sites

Thank you guys. The 404 page thing worked great, FYI if anyone else wants to do something similar heres what I'm using now:

 

<?php
include_once "scripts/connect_to_mysql.php"; ///Connects to DB
$username = $_SERVER['REQUEST_URI']; /// Gets the username from the URL (incl a forward slash)

$username = ltrim($username, '/'); /// Removes the forward slash

$sql = mysql_query("SELECT id FROM myMembers WHERE username='$username'"); /// Queries the DB, matches the usernames and returns the user's ID

while($row = mysql_fetch_array($sql)){ /// Sets the variable $id from the DB
    $id = $row["id"];
}

$profilelocation = "http://domain.com/profile.php?id=$id"; /// Sets the user's profile link
$page = file_get_contents($profilelocation);
echo $page; /// echos out the final profile page
?>

 

Regards,

Anim8r

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.