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
OutBoundLinker - Help!
Old 11-29-2008, 04:47 PM OutBoundLinker - Help!
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Hey,

I needed an outbound link system and i got it to work on my localhost (Defualt php, .htaccess, apache settings), But when i try it on my server it doesn't work.

MainPage
Redirect to Google

And the code:

PHP Code:
<html>
<head>
<title>Out Bound Linker</title>
<!--
    :: Out Bound Linker ::
    COPYRIGHT 2008 Decaf Productions
    Made By, Adam Shannon
    
    You may use this script as long as you keep this notice in.
-->
</head>
<body>
<?php
    
// Get there link number
    
$id $_GET['id'];
    
##################################################
    #                        Start LINKS                        #
    ##################################################
    
$link[0] = 'http://decafproductions.com';
    
$link[1] = 'http://decafproductions.com';
    
$link[2] = 'http://google.com';
    
$link[3] = 'http://yahoo.com';
    
$link[4] = 'http://msn.com';
    
$link[5] = 'http://aol.com';
    
$link[6] = 'http://cbs.com';
    
$link[7] = 'http://php.net';
    
$link[8] = 'http://cnn.com';
    
$link[9] = 'http://decafproductions.com/~adam';
    
##################################################
    #                        End LINKS                            #
    ##################################################
    
if ($id) {
        
$out $link[$id];
        
// Send them to the link they want.
        
header("Location: $out");
    } else {
        
// If no link then send them back to there last page.
        
$back $_SERVER['HTTP_REFERER'];
        print 
"Error Getting Link, Go <a href='$back'>Back</a>.";
    }
?>
</body>
</html>
I'm thinking its something with the header("Location: $out"); command.

I'm stuck, thanks in advance.
__________________

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 Decaf; 11-29-2008 at 06:06 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
 
Register now for full access!
Old 11-30-2008, 01:10 AM Re: OutBoundLinker - Help!
Average Talker

Posts: 20
Trades: 0
Because of the way your php is set up (i.e. it's processed after html is written to the page), the headers have already been sent when you try to do that header("Location: xxx") redirect.

The easiest way to fix this would be to split it up into two files and have it post instead of get. The other way would be to check if the form has been submitted already before outputting any HTML. That way, if it has, you can redirect and no headers will have been sent yet.
JeremyApp is offline
Reply With Quote
View Public Profile
 
Old 11-30-2008, 01:20 AM Re: OutBoundLinker - Help!
Average Talker

Posts: 20
Trades: 0
Never mind the last comment - fixed it up for you. Here's the code that'll make it work. Notice that I don't send anything to output until I've decided whether or not to set the header.

You can test it out here:

http://www.snipiti.com/out_test.php - shows the error

Code:

<?php
if(isset($_GET['id'])) {

    // Get there link number
    $id = $_GET['id'];
    ##################################################
    #                        Start LINKS                        #
    ##################################################
    $link[0] = 'http://decafproductions.com';
    $link[1] = 'http://decafproductions.com';
    $link[2] = 'http://google.com';
    $link[3] = 'http://yahoo.com';
    $link[4] = 'http://msn.com';
    $link[5] = 'http://aol.com';
    $link[6] = 'http://cbs.com';
    $link[7] = 'http://php.net';
    $link[8] = 'http://cnn.com';
    $link[9] = 'http://decafproductions.com/~adam';
    ##################################################
    #                        End LINKS                            #
    ##################################################
    $out = $link[$id];
        // Send them to the link they want.
        header("Location: $out");
} else {
        // If no link then send them back to there last page.
        
    $back = $_SERVER['HTTP_REFERER'];
    echo <<<HTMLPAGE
    <html>
<head>
<title>Out Bound Linker</title>
<!--
    :: Out Bound Linker ::
    COPYRIGHT 2008 Decaf Productions
    Made By, Adam Shannon
    
    You may use this script as long as you keep this notice in.
-->
</head>
<body>
Error Getting Link, Go <a href='$back'>Back</a>.
</body>
</html>
HTMLPAGE;
}
?>

Last edited by JeremyApp; 11-30-2008 at 01:25 AM..
JeremyApp is offline
Reply With Quote
View Public Profile
 
Old 11-30-2008, 12:23 PM Re: OutBoundLinker - Help!
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
ya, i realized at 10:30 that i had the html tags in, but my computer was shut off.

Thanks man!
__________________

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

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Reply     « Reply to OutBoundLinker - Help!
 

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.25495 seconds with 12 queries