View Single Post
01-28-2011, 03:59 PM
#4
derek lapp is offline derek lapp
Status: design rockstar
Join date: Jan 2005
Location: guelph, ontario
Expertise:
Software:
 
Posts: 2,246
iTrader: 0 / 0%
 

derek lapp is on a distinguished road

  Old

Originally Posted by lplplpx3 View Post
This code is from the bottom of a php contact submission form. How can I change the code to direct to, or display a specified web page if the email was successful and another if not in order to stop this generic page from showing. Thanks.

<?php if(isset($emailSent) == true) { ?>
<div class="ok">
<h1>Thanks, <?php echo $name;?></h1>
<p>Your email was successfully sent. We will be in touch soon.</p>
</div>
<?php } ?>


<?php if(isset($hasError) ) { ?>
<div class="error2">There was an error submitting the form.</div>
<?php } ?>
using a header re-direct is useless here: the script itself has already done the success/fail check and given you conditions for each. just read through the code piece by piece.

the top chunk is what happens upon successful completion. the second chunk is what happens if an error is thrown. if you want to change what gets outup, just change the html betwene the <?php ?> tags:

Code:
<?php if(isset($emailSent) == true) { ?>
<!-- giant thank you graphic -->
<img src="images/thanks.jpg" alt="Thank you for your submission" />
<?php } ?>

<?php if(isset($hasError) ) { ?>
<!-- error was thrown -->
<img src="images/error.jpg" alt="stimpy, you iiidiot!" />
<?php } ?>