Jump to content

php redirect


lee123

Recommended Posts

hi all, i have a prob, at the end of this script it send you to a either 2 blank page with one's  sayings

 

  echo "<a href='javascript:history.back()'>Your message is successfully emailed PLEASE CLICK HERE TO RETURN</a>";

  } else {

  echo "<a href='javascript:history.back()'>SORRY YOU HAVE PROVIDED AN IMVALID CODE PLEASE CLICK HERE TO RETRY</a>";

 

i would like to send them to 2 pages i have setup eg a www.thankyou.com and a www.wrongcode.com (this page with a back button) any help please, here is the full php file

 

<?php

session_start();

if( $_SESSION['6_letters_code'] == $_POST['6_letters_code'] && !empty($_SESSION['6_letters_code'] ) ) {

  $to = "[email protected]";

  $email_subject = "This is the email subject";

  $name = $_POST['name'];

  $email = $_POST['email'];

  $number = $_POST['number'];

  $message = $_POST['message'];

  $email_body = "Name " . $name . " . Email Address " . $email . " . Phone Number " . $number . ". Message: " . $message;

  mail($to, $email_subject, $email_body);

  echo "<a href='javascript:history.back()'>Your message is successfully emailed PLEASE CLICK HERE TO RETURN</a>";

  } else {

  echo "<a href='javascript:history.back()'>SORRY YOU HAVE PROVIDED AN IMVALID CODE PLEASE CLICK HERE TO RETRY</a>";

  }

  ?>

 

thanks lee

Link to comment
https://forums.phpfreaks.com/topic/170065-php-redirect/
Share on other sites

thanks TeNDoLLA

 

it dont seem to work for me, as im new to all this its prob me not understanding right, is this were i should put it

 

<?php

session_start();

if( $_SESSION['6_letters_code'] == $_POST['6_letters_code'] && !empty($_SESSION['6_letters_code'] ) ) {

  $to = "[email protected]";

  $email_subject = "This is the email subject";

  $name = $_POST['name'];

  $email = $_POST['email'];

  $number = $_POST['number'];

  $message = $_POST['message'];

  $email_body = "Name " . $name . " . Email Address " . $email . " . Phone Number " . $number . ". Message: " . $message;

  mail($to, $email_subject, $email_body);

  if (code_is_right)

  {

    header('Location: http://www.anglianpat.com/test/thankyou.html');

  }

  else

  {

    header('Location: http://www.anglianpat.com/test/wrongcode.html');

  }

 

 

thanks lee

Link to comment
https://forums.phpfreaks.com/topic/170065-php-redirect/#findComment-897920
Share on other sites

<?php
session_start();
if ($_SESSION['6_letters_code'] == $_POST['6_letters_code'] && !empty($_SESSION['6_letters_code'])) {
$to = "[email protected]";
$email_subject = "This is the email subject";
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$message = $_POST['message'];
$email_body = "Name " . $name . " . Email Address " . $email . " . Phone Number " . $number . ". Message: " . $message;
mail($to, $email_subject, $email_body);
die(header('Location: http://www.anglianpat.com/test/thankyou.html'));
} else {
die(header('Location: http://www.anglianpat.com/test/wrongcode.html'));
}
?>

Link to comment
https://forums.phpfreaks.com/topic/170065-php-redirect/#findComment-898777
Share on other sites

What about this snippet?

 

echo "<b>Thank you! Your message is successfully emailed.";

echo "<meta http-equiv=Refresh content=2;url=http://www.anglianpat.com/test/thankyou.html>";

 

echo "<b>SORRY YOU HAVE PROVIDED AN IMVALID CODE!!";

echo "<meta http-equiv=Refresh content=2;url=http://www.wrongcode.com>";

Link to comment
https://forums.phpfreaks.com/topic/170065-php-redirect/#findComment-898980
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.