cascer1 Posted October 28, 2011 Share Posted October 28, 2011 hello, so i have this contact page on my website, but i want people to actually know if the mail got sent or not, so i first have contact.php, which sends all the information to sendmail.php, which in turn tells redirect.php wether or not the mail was sent, and redirect.php then shows this information for the user to see, and has a 10 second timer before users get sent back.. here is the website: http://hcg.drokz.eu.clanservers.com/ all files are in the same folder so here is my code: <?php $url1 = 'redirect.php?sent=sent'; $url2 = 'redirect.php?sent=fail'; $timeout = 0; ?> <?php $to = "[email protected]"; $name = $_REQUEST['name'] ; $subjectm = $_REQUEST['subject'] ; $subject = "contact form entry on the hcg website by $name with the subject $subjectm"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; ?> <?php if($sent) {header('Refresh: ' . $timeout . ';url=' . $url1); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url1); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url1); ?>";}, <?php echo($timeout * 1000); ?>); </script> <?php } ; ?> <?php else {header('Refresh: ' . $timeout . ';url=' . $url2); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url2); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url2); ?>";}, <?php echo($timeout * 1000); ?>); </script> <?php } ; ?> <a href='contact.php'> this page should redirect you, if nothing happens, click here! </a> <?php $sent = $_GET['sent'] ; ?> <?php $url = 'contact.php'; $timeout = 10; ?> <?php header('Refresh: ' . $timeout . ';url=' . $url); ?> <meta http-equiv="refresh" content="<?php echo($timeout) ?>;url=<?php echo($url); ?>"> <script type="text/javascript"> setTimeout(function(){window.location.replace("<?php echo($url); ?>";}, <?php echo($timeout * 1000); ?>); </script> <h1> <?php if($sent == sent) {echo "Success!" } ; elseif($sent == fail) {echo "Failure!" } ; ?></h1> <?php if($sent == sent) {echo "your email has been sent successfully and we will reply as soon as we can."} ; elseif($sent == fail) {echo "we have encountered a problem while sending your email, please try again!"} ; ?> <p> <a href='contact.php'> this page will redirect you in 10 seconds, if nothing happens or you can't wait, click here! </a> Quote Link to comment https://forums.phpfreaks.com/topic/250014-i-cant-seem-to-get-this-page-to-redirect/ Share on other sites More sharing options...
cascer1 Posted October 28, 2011 Author Share Posted October 28, 2011 i know it's a messy code, but i'm new to php coding so cut me some slack Quote Link to comment https://forums.phpfreaks.com/topic/250014-i-cant-seem-to-get-this-page-to-redirect/#findComment-1283134 Share on other sites More sharing options...
cascer1 Posted October 29, 2011 Author Share Posted October 29, 2011 bump Quote Link to comment https://forums.phpfreaks.com/topic/250014-i-cant-seem-to-get-this-page-to-redirect/#findComment-1283305 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.