Jump to content

Universal link


JackCode

Recommended Posts

Hey,

 

I'm assuming you mean when your user has logged in or click on a link, you want it to take them to their own specific member page?

 

For the url, you'd need something like

$url = 'member_page.php?member_id=${member_id}'

 

Then, on the page, you'd need a $_REQUEST['member_id'] to grab that id and load their specific page.

 

Hope this helps. If you need any clarification or if I assumed incorrectly, let me know.

Link to comment
Share on other sites

I asume you want to have some sort of userlist, with a link to each user's profile.

 

So, if this is the case, you can do something like this:

 

Members.php:

<?php
$sql = mysql_query("SELECT * FROM `users` ORDER BY `id`");
if ($sql) {
    while ($info = mysql_fetch_array($sql)) {
        //Some userinfo here.
        //The link to the user his profile.
        echo '<a href="profile.php?user='.$info["id"].'">More info about this user.</a>';
    }
}else{
    die(mysql_error());
}
?>

Profile.php:

if (!isset($_GET['user']) || $_GET['user'] == "") {
    echo 'Please insert a user to lookup..';
    exit;
}else{
    $sql = mysql_query("SELECT * FROM users WHERE id='".$_GET['user']."'");
    if (mysql_num_rows($sql)>0) {
	while ($info= mysql_fetch_array($sql)) {
            //User information to display.
        }
    }else{
        echo 'This user isn\'t in our database!';
        exit;
    }
}
Link to comment
Share on other sites

Hey,

 

I'm assuming you mean when your user has logged in or click on a link, you want it to take them to their own specific member page?

 

For the url, you'd need something like

$url = 'member_page.php?member_id=${member_id}'
 

Then, on the page, you'd need a $_REQUEST['member_id'] to grab that id and load their specific page.

 

Hope this helps. If you need any clarification or if I assumed incorrectly, let me know.

 

Thank you this is exactly what I needed. For a request do you just request for the ID in the page Im linking from?

Link to comment
Share on other sites

Thank you this is exactly what I needed. For a request do you just request for the ID in the page Im linking from?

 

The $_REQUEST is actually a combination of $_GET and $_POST. I was always taught to use $_REQUEST instead. You saw how the url was passed into the page? Well it works just from that. It takes the id from the url.

 

By the way, please, please, please make sure to run filters on that string. As of PHP5, we have filter functions. So use the filter functions for integers and when you've cleaned & validated it, then let it touch the database.

 

If you need any more help, let me know. I can go through it with you.

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.