php redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nick2price
Forum Newbie
Posts: 18
Joined: Fri Nov 13, 2009 5:49 pm

php redirect

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: php redirect

Post by John Cartwright »

Yes. :)
nick2price
Forum Newbie
Posts: 18
Joined: Fri Nov 13, 2009 5:49 pm

Re: php redirect

Post 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?
Post Reply