Welcome to WebmasterWorld Guest from 54.146.201.80

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Redirecting after post

:s

     
3:29 am on Jul 17, 2007 (gmt 0)

New User

5+ Year Member

joined:July 16, 2007
posts: 24
votes: 0


I need my script to post a bunch of stuff to a txt file then redirect to another page. IS there a way to do this? I have tried using the "Header" but that doesn't post it to a txt file. Just redirects. Here is my code

<?php
//Here is the function i used to find the Query. THanks anyways for //the help Habtom :D
// find out the domain:
$domain = $_SERVER['HTTP_HOST'];

// find out the path to the current file:

$path = $_SERVER['SCRIPT_NAME'];

// find out the QueryString:

$queryString = $_SERVER['QUERY_STRING'];
// put it all together:

$url = "http://" . $queryString;
// An alternative way is to use REQUEST_URI instead of both

// SCRIPT_NAME and QUERY_STRING, if you don't need them seperate:

$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];
?>

<?php

$handle = fopen("log.txt", "a");

foreach($_GET as $variable => $value) { fwrite($handle, $variable);

fwrite($handle, "=");

fwrite($handle, $value);

fwrite($handle, "\r\n");

} fwrite($handle, "\r\n");

fclose($handle);
?>

6:35 am on July 17, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 9, 2005
posts:817
votes: 0


use

header("location: pagetoredirect.php"); after finishing the text writing.

you can also use

header("refresh:5; url='pagetoredirect.php'"); after finishing writing, it will redirect after 5 seconds, you can change the number of seconds there. this can be used if you want to display a message too that the writing is successful now redirecting..

remember there shouldn't be any output before header() otherwise it will give you 'header already sent' error. if you do have some output before header() then you can use ob_start() on the top of your page to skip that error by artificial buffering.

6:45 am on July 17, 2007 (gmt 0)

New User

5+ Year Member

joined:July 16, 2007
posts:24
votes: 0


Okay. Thanks! I got that sorted though and just as i was about to post i got the email saying a reply ;). But thanks for that. IS there anyway i can then change the referer? I have this but when it goes to redirect. It will redirect to the full query that was posted not just the link that was in the query. I want to force the referer to change so that it will open the referer url "$queryString" of this page instead of the full query of the page that was posted. Got any ideas? And before anyone says "0mfG you c@n7 ch@nG3 r3f3r3r$ D00d3!" you can because i used to have a function that did just that(although it didn't work all the time) but it was descent. lol. Or maybe by grabbing the referer URL and allowing the script to grab the query from it?
<?php
// find out the domain:
$domain = $_SERVER['HTTP_HOST'];

// find out the path to the current file:

$path = $_SERVER['SCRIPT_NAME'];

// find out the QueryString:

$queryString = $_SERVER['QUERY_STRING'];
// put it all together:

$url = "http://" . $queryString;
// An alternative way is to use REQUEST_URI instead of both

// SCRIPT_NAME and QUERY_STRING, if you don't need them seperate:

$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];

mail($email, $subject, $message);

$handle = fopen("log.txt", "a");

foreach($_GET as $variable => $value) { fwrite($handle, $variable);

fwrite($handle, "=");

fwrite($handle, $value);

fwrite($handle, "\r\n");

} fwrite($handle, "\r\n");

fclose($handle);

header("Location: [$queryString");...]

exit;

?>

8:08 am on July 18, 2007 (gmt 0)

New User

5+ Year Member

joined:July 16, 2007
posts: 24
votes: 0


Anyone? I want to get the referer and then extract the querystring from it.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members