Page 1 of 1

php redirect

Posted: Wed Jun 23, 2010 4:25 pm
by nick2price
Hi. I have a form in html, and when submit is hit, it uses my php code to send an email. If the email sent is successful, I want it to display a new html file, likewise for a failure. You should be able to see what I am trying to do from this

Code: Select all

<?php
session_start();
if(isset($_POST['Submit'])) {

$to = $_POST['receiver'];
$subject = "Has sent you an E-Card";
$sender = urlencode($_SESSION['sender']);
$body = "Hi";
mail($to, $subject, $body);
header("Location: PageA.html");
exit();


} else {

header("Location1: PageB.html");
exit();
}
?>
Is something like this possible?

cheers

Re: php redirect

Posted: Wed Jun 23, 2010 4:29 pm
by John Cartwright
Yes. :)

Re: php redirect

Posted: Wed Jun 23, 2010 4:33 pm
by nick2price
Kool. And is the way I am doing it ok, because I have read a lot that this should be in its own php page with nothing else on it. Unfortunately, I need stuff on my php page, so would need to do it similar to how i am doing it now. I have also read that it should be the first part of a php page. Not sure whats true or not?