Results 1 to 5 of 5

Thread: different type of redirect script

  1. #1
    Join Date
    Dec 2007
    Location
    Little Elm, TX
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default different type of redirect script

    HI Everyone,
    I have a website (http://www.worstchristmaslights.com) where viewers can vote on the different christmaslight display pictures (each picture is it's own url). After voting they are taken to a thank you screen and then they must click the back button to get back to the picture.
    I am looking for a redirect script that will take them right back to the webpage they came from without having to click on the back button.

    I've seen several scripts that will redirect to an exact URL but not one that will redirect back to the refering URL.

    Any help would be appreciated.

    Steve

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    If you have access to the php code in rating.php, you could add this line to it so that it redirects back to that site:

    Code:
     header('Location: http://yourdomain.com/'.$_POST['fname']);
    or if you want to give it a little while before redirecting, you could use something like the following:

    Code:
     header('Redirect: 3; url=http://yourdomain.com/'.$_POST['fname']);
    Be sure to place that before anything gets sent to the browser.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Dec 2007
    Location
    Little Elm, TX
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, first off, thank you for the help, but...
    I've tried putting that snipet in several different places but no success.

    Here is the main part of rating.php
    <!-- content-wrap starts here -->
    <?php include("../sidenav.php"); ?>


    <div id="main">

    <p style="text-align: center">

    <img border="0" src="../images/lights01.gif" width="551" height="46" align="center" style="border-width: 0px">
    </p>
    <?php
    include "header.txt";
    ?>
    <table align=center border=1 style="margin-left: 35px; font-size: 13px; border: #449944 solid 2px;">
    <tr>
    <td align=center>

    <?php
    $name = $_POST['fname'];
    $rat = $_POST['rate'];
    //echo "----$name";
    //echo "---------------$rat";
    $ser=$_SERVER['HTTP_HOST'];
    $ref=$_SERVER['HTTP_REFERER'];
    $host= parse_url($ref);
    //echo "-------$host[host]-------";

    $fname = $name;
    $rip = $_SERVER['REMOTE_ADDR'];
    $lines = file("./rateval.txt");
    $rated = false;

    if($ser == $host[host])
    {
    foreach ($lines as $line_num => $line)
    {
    //echo $line."<br>";
    $firstPos = strpos($line,$rip);
    //echo($firstPos);
    if(!($firstPos === false))
    {
    $secPos = strpos($line,$fname);

    if(!($secPos === false))
    {
    //echo($secPos."-".$fname."-".$line);
    $rated=true;
    break;
    }
    }
    }

    if($rated === false && $name!='')
    {
    $open = fopen("./rateval.txt", "a");
    fwrite($open,$fname."****".$rip."####"."0000"."%%%%".$rat);
    fwrite($open,"\n");
    fclose($open);
    }

    echo("<div align=left style=\"margin-left: 25px; font-size: 13px; border: #449944 solid 1px; padding: 12px;\">");
    include "message.txt";
    echo("</div>");

    ?>
    </td>
    </tr>
    </table>
    <?php
    include "footer.txt";
    }
    ?>

    If I put the new code line anywhere after <?php include("../sidenav.php"); ?> , I get the following type error -
    Warning: Cannot modify header information - headers already sent by (output started at /home/.venus/scobb77/worstchristmaslights.com/sidenav.php:59) in /home/.venus/scobb77/worstchristmaslights.com/HRAT/rating.php on line 73

    I guess which is why you said to place it before anything was sent to the browser. But if I place it before sidenav.php, nothing happens.

    Any suggestions?

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Probably your best bet would be to output a javascript snippet to the browser. Something like the following should work for you:

    Code:
     <script type="text/javascript">
       window.location.href='http://yourdomain.com/<?php echo $_POST['fname'];?>';
     </script>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Dec 2007
    Location
    Little Elm, TX
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I thought that was going to do the trick and it did send me right back to my original starting point but it also seemed to clear the voting info. If I take the code out and revote, or re-click on the link to that page, the vote totals return.
    Again, thanks so much for the help on this.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •