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
https://forums.phpfreaks.com/topic/252924-covering-up-with-any-text/
Share on other sites

Sorry, misunderstood the question.  Try using a custom 404 page and use the following:

 

$userid=explode ("/",$url); // requested URL

echo $userid[1]; // or $userid[3] if using http://www.domain.com/id instead of just www

 

file_get_contents("http://mydomain.com/404.php?id="); //to reflect the output of the requested user

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.