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("Locatio n: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_ad dress))
{
$valid_message = false;
}
else
{
mail( "my email address", "feedback form", $message, "from:
$email_address" );
$valid_message = true;
}
?>"
<input name="email_add ress" 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("Locatio n: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.
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("Locatio n: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_ad dress))
{
$valid_message = false;
}
else
{
mail( "my email address", "feedback form", $message, "from:
$email_address" );
$valid_message = true;
}
?>"
<input name="email_add ress" 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("Locatio n: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.
Comment