Jump to content

[SOLVED] user specific links


solidusjoe

Recommended Posts

let's try this again, my previous topic went unsolved for some time now.

 

Basically what I am trying to do is create a page that will redirect a user to another page. however this page has to use a variable from the mysql database to know what url to send the person to, and the url of this redirection page has to carry their specific user id number as well as an id number for the site they are being sent to.

 

Broken down, by theory it should work like this:

1. User number 123 clicks on a link to a website on one of my pages, that is supposed to direct them to the site associated with the site id 456.

2. the link would look like mysite.com/out.php?user=123&site=456

3. The out.php page would read in the url associated with id 456 and then redirect the user to that url.

 

I hope someone can help me out because I am very stuck and this is one of the most crucial points of my project. I will also be needing to use a session ID to make sure the user is clicking on links with their own unique user id.

 

Can someone please help me solve this problem? I'm really new to php, but I need to be able to do this. Thank you very much in advance.

Link to comment
Share on other sites

I don't fully understand you, but give this a try:

 

<?php

session_start();

$user = intval($_GET["user"]);
$site = intval($_GET["site"]);

if($_SESSION["userid"] != $user) {
die("Invalid user ID");
}

$query = mysql_query("SELECT url FROM table WHERE userid = {$user} AND siteid = {$site}") or die(mysql_error());
list($url) = mysql_fetch_row($query);

header("Location: {$url}");

?>

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.