Jump to content

Redirect not working after making a POST/GET


sudheep_divakar@yahoo.com

Recommended Posts

Hi Everyone,

 

I am a novice in PHP. Here I have 2 pages, one page with a textbox and button and other page which has code to redirect to another website with the post value as querystring. When I tried to print the post data in the second page after posting, it worked fine, but when I have the header function in the second page the application hangs.

 

Below is the code from these pages

 

First Page 

<html>

<body>

<form action="welcome.php" method="get">

Search Phrase: <input type="text" name="fname" />

<input type="submit" />

</form>

</body>

</html>

 

Second Page

 

<?php

header( 'Location: http://www.google.com' ) ;

?>

 

Since I have problem in redirecting, the second page does not have code to pass query string data.

 

How can I get this working ?

 

Regards

SD

 

[attachment deleted by admin]

On your welcome.php you have blank spaces before your code. When you set a session or use the header function you have to do so before you put anything out to the browser. Any white space before the code will be put out to the browser first.

Read this: http://us.php.net/manual/en/function.header.php

If you still have problems make sure that your are saving the file without BOM. This is something that happened to me for the longest till I changed the way my text editor was saving my files.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.