You are here: How to redirect after form submit? « PHP Programming Language « IT news, forums, messages
How to redirect after form submit?

Posted by deko on 06/12/06 14:35

I have a basic feedback form with a submit button.

After the "send" button is clicked, I want the user to be redirected to a
different page that says "Your message has been sent."

How do I do this?

I've tried using:

header("Location:http://www.mysite.com/send-confirm.php");

But here's the error I get:

Warning: Cannot add header information - headers already sent by (output started
at ...

Here's the code:

<form action= "
<?php
$message = trim($_REQUEST['message']);
$email_address = trim($_REQUEST['email_address']);
if (empty($message) || empty($email_address))
{
$valid_message = false;
}
else
{
mail( "my email address", "feedback form", $message, "from:
$email_address" );
$valid_message = true;
}
?>"
<input name="email_address" type="text" size="30"/><br />
<textarea name="message" rows="12" cols="23"></textarea><br />
<input type="submit" value="Send">
</form>
<?php
if ($valid_message)
{
echo "valid message";
header("Location:http://www.mysite.com/send-confirm.php");
exit();
}
else
{
echo "invalid message";
}
?>

How do I redirect after the user clicks the send button?

Thanks in advance.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация