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
Redirect Page Problem
Old 10-31-2006, 12:43 PM Redirect Page Problem
Skilled Talker

Posts: 69
Trades: 0
Hello again,

I've been working on a download tracker for my website. Unfortunately, it doesn't work. When you click on the download link, it brings you to this page, which then adds to the database (does work, the count has gone up in the mySQL) but then it redirects me to my homepage when it should redirect to the variable $downloadlink

PHP Code:
<?php
     $id 
$_GET['id'] ;

    
//CONNECT TO THE DATABASE STUFF REMOVED

    //GET ALL OF THE ENTRIES FROM ONE CATEGORY IN A DIFFERENT ORDER
    
$result mysql_query("SELECT * FROM `downloadtracker` WHERE `id` = '$id' ");
    if (!
$result) { 
    echo 
mysql_error(); 
    exit; 
    }
    while (
$array mysql_fetch_array($result)) {
    
$link $array['downloadlink'];
    
$number $array['downloads'];

    
$number++;

    
mysql_query("UPDATE `downloadtracker` SET `downloads` = $number WHERE `id` = $id LIMIT 1;");

    
$host  $_SERVER['HTTP_HOST'];
    
$uri  rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    
header("Location: http://$host$uri/$downloadlink");

    }

?>
Any help would be great, because I don't know why it doesn't work.

Thanks,

*~* Reality15
Reality15 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-31-2006, 12:55 PM Re: Redirect Page Problem
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You have this line:
$link = $array['downloadlink'];

So I think you should have:
header("Location: http://$host$uri/$link");

<edit>
Also $_SERVER['PHP_SELF'] will return the current filename
</edit>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 10-31-2006 at 12:56 PM..
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 10-31-2006, 01:38 PM Re: Redirect Page Problem
Skilled Talker

Posts: 69
Trades: 0
Alright, now the link in the address bar is correct, but instead of starting the download, it just gives me a message on the screen:

No input file specified.

Any clues now?
Reality15 is offline
Reply With Quote
View Public Profile
 
Old 11-02-2006, 04:35 AM Re: Redirect Page Problem
Novice Talker

Posts: 5
Name: alamsyah
Trades: 0
try change :

header("Location: http://$host$uri/$downloadlink");

with this

echo "<script>window.location.href=\"http://$host$uri/$downloadlink\";</script>";
__________________

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

Please login or register to view this content. Registration is FREE
alamster is offline
Reply With Quote
View Public Profile Visit alamster's homepage!
 
Reply     « Reply to Redirect Page Problem
 

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