Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
need help for a goto.php redirect script??
Old 02-04-2010, 10:17 AM need help for a goto.php redirect script??
Average Talker

Posts: 22
Name: Rikesh Bajracharya
Trades: 0
hi i have a database like this

id | sitename | url
1 ABC abc.com
2 XYZ xyz.com
3 PPP ppp.com

i wanted to create a redirect script like www.mysite.com/goto.php?url=(id number) and that id number would lead to related url respectively.

for example if i try www.mysite.com/goto.php?url=2 then xyz.com will open
and if i try www.mysite.com/goto.php?url=1 then abc.com will open

i would be very thankful if anyone helps me.
regards.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
easyflashgames is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-04-2010, 12:47 PM Re: need help for a goto.php redirect script??
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I assume you already have a sql connection and you'll need to specify the correct table in the query:

PHP Code:
<?php
$id 
$_GET['id'];
//validate id
if(!is_numeric($id)) :
?>
Invalid url id
<?php
else :
     
$query "SELECT url FROM tableName WHERE id = '$id';";
     
$res = @mysql_query($query);

     if(!
$res) :
?>
An error has occured
<?php
     
else :
          if(
$row = @mysql_fetch_array($res)) :
               
header('Location: ' $row[0]);
          else :
?>
URL could not be found
<?php
          
endif;
     endif;
endif;
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 02-04-2010 at 12:50 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to need help for a goto.php redirect script??
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.78673 seconds with 12 queries