...

View Full Version : Switching websites using PHP



thinker987
01-28-2007, 05:45 PM
I need some advice on users being able to switch to other websites from my own using PHP.

When you place the mouse on an image in my table grid, at the bottom of the screen you can see the name of my website followed by the unique key identifier, it looks as follows:

http://www.mysite.com/url.php?id=1

The field 'id' is the unique key in a sql table. I need some PHP that will pick up the key field 'id' from the screen, read the table using the 'id' key field, and retrieve the contents of the field 'url' from the sql table record. I then need the user to switch automatically to the website indicated by this new url.

As a user all that should happen is you select the image on the page and you should switch automatically to the website associated with the image.

Can you assist in the construction of this PHP statement?

Many Thanks

martialtiger
01-28-2007, 06:44 PM
I need some advice on users being able to switch to other websites from my own using PHP.

When you place the mouse on an image in my table grid, at the bottom of the screen you can see the name of my website followed by the unique key identifier, it looks as follows:

http://www.mysite.com/url.php?id=1

The field 'id' is the unique key in a sql table. I need some PHP that will pick up the key field 'id' from the screen, read the table using the 'id' key field, and retrieve the contents of the field 'url' from the sql table record. I then need the user to switch automatically to the website indicated by this new url.

As a user all that should happen is you select the image on the page and you should switch automatically to the website associated with the image.

Can you assist in the construction of this PHP statement?

Many Thanks

I can do this for you. Feel free to PM if you still need help with this.

Erockrm1
01-28-2007, 10:10 PM
If I understand what you asked it should look something like this...




// this file should go at the top of url.php

if (isset($_REQUEST['id']))
{
$sql = mysql_query( "SELECT `url` FROM `sqltable` WHERE `id`='$_REQUEST[id]' ")
or die (mysql_error());

$row = mysql_fetch_array($sql);

echo '
<script>
window.location="$row[url]"
</script>
';
}



Let me know if it works :D

thinker987
01-29-2007, 10:21 PM
Hi all

Just to confirm, martialtiger has provided some code which resolved this problem, thanks for all of your input

Lee Stevens
01-30-2007, 01:06 AM
Or in the loop use header("Location: 'URL BY ID'") function, instead of script....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum