homepage Welcome to WebmasterWorld Guest from 54.198.8.124
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Redirecting after post
:s
nedloh




msg:3396563
 3:29 am on Jul 17, 2007 (gmt 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);
?>

 

phparion




msg:3396686
 6:35 am on Jul 17, 2007 (gmt 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.

nedloh




msg:3396694
 6:45 am on Jul 17, 2007 (gmt 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;

?>

nedloh




msg:3397895
 8:08 am on Jul 18, 2007 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved