Skip to main content
September 4, 2009
Answered

URL in PHP

  • September 4, 2009
  • 1 reply
  • 444 views

Not sure how to really ask this question.  I know what I want - but not how to explain it.

I want to be able to send a user back to the page they came from using an if/else statement.  For example:

if( $_POST['word'] )

{

   Do this!

}

else

{

     ???????????

}

The ?????? should be a url back to the first page (page where user came from).  I know the url I want to use - just not how to code it to send them back there.

Please help.

This topic has been closed for replies.
Correct answer David_Powers

Moved to the Dreamweaver Application Development forum, which deals with PHP and other server-side issues.

To redirect to another URL with PHP, use the header() function.

header('Location: http://www.example.com/anotherpage.php');

exit;

It's important that no output is sent to the browser before calling header(). See http://kb2.adobe.com/community/publishing/505/cpsid_50572.html for an explanation.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
September 5, 2009

Moved to the Dreamweaver Application Development forum, which deals with PHP and other server-side issues.

To redirect to another URL with PHP, use the header() function.

header('Location: http://www.example.com/anotherpage.php');

exit;

It's important that no output is sent to the browser before calling header(). See http://kb2.adobe.com/community/publishing/505/cpsid_50572.html for an explanation.