Hi,
I am just learning PHP and I have an issue with a site where an include for a file that once showed up at the end of a transaction no longer shows up.
What does not make sense to me is there is a piece of code that checks to see if an email went out and if so, it is supposed to "include" another file that basically draws a Thank You page.
However, the code to check for the email going out seems to be before the email goes out. So I am confused on the order of execution.
Is it possible to check for an even happening before it happens in PHP?
Here is an example:
if ((isset($_SESSION['ordersent']))&&($_SESSION['ordersent']=="Sent")) {
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head></head><body>';
echo "<center><br /><br /><br /><br /><br /><br /><div style='width: 500px; font-size: 26px; font-weight: bold;'>";
echo "Your order has been sent. You may now close this browser window.</div>";
echo "</center></body></html>";
} else {
$v=true;
$v=mail($to, $subject, $HTMLmsg, $headers);
$g=mail("myemail@email.com",$subject,$HTMLmsg2,$headers2);
if($v) {
$_SESSION['ordersent']="Sent";
$ErrorMsg="";
//show confirmation page
//This is the part that does not seem to happen...
include("email.php");
if (isset($_GET['clear'])) {
$shield=$_GET['clear'];
if ($shield==$_SESSION['shield']) {
foreach($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
}
$_SESSION['cart_empty']=1;
$cart=array("desc" => "FootLog","qty" => "0", "price" => "19.95");
$_SESSION["Item1"]=$cart;
$cart=array("desc" => "BodyLog","qty" => "0", "price" => "19.95");
$_SESSION["Item2"]=$cart;
$cart=array("desc" => "FootMag","qty" => "0", "price" => "15.95");
$_SESSION["Item3"]=$cart;
$cart=array("desc" => "Foot Cream","qty" => "0", "price" => "29.95");
$_SESSION["Item4"]=$cart;
$cart=array("desc" => "ToesEase®","qty" => "0", "price" => "19.95");
$_SESSION["Item5"]=$cart;
$cart=array("desc" => "ToeSoak®","qty" => "0", "price" => "19.95");
$_SESSION["Item6"]=$cart;
$shield=md5(time());
$_SESSION['shield']=$shield;
}
}
else
{
$ErrorMsg="Email not sent, there was a problem";
}
}
}
else
{
$Item1=$_SESSION[Item1];
$Item2=$_SESSION[Item2];
$Item3=$_SESSION[Item3];
$Item4=$_SESSION[Item4];
$Item5=$_SESSION[Item5];
$Item6=$_SESSION[Item6];
I have done some programming in VB, but I am having difficulty in following the logic of this code. For example, in my mind, the $v variable, should 1) be set before the else, not after; and 2) should not receive the value of the email information before the if($v) statement. Am I missing something?
Any help would be appreciated
I am just learning PHP and I have an issue with a site where an include for a file that once showed up at the end of a transaction no longer shows up.
What does not make sense to me is there is a piece of code that checks to see if an email went out and if so, it is supposed to "include" another file that basically draws a Thank You page.
However, the code to check for the email going out seems to be before the email goes out. So I am confused on the order of execution.
Is it possible to check for an even happening before it happens in PHP?
Here is an example:
if ((isset($_SESSION['ordersent']))&&($_SESSION['ordersent']=="Sent")) {
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head></head><body>';
echo "<center><br /><br /><br /><br /><br /><br /><div style='width: 500px; font-size: 26px; font-weight: bold;'>";
echo "Your order has been sent. You may now close this browser window.</div>";
echo "</center></body></html>";
} else {
$v=true;
$v=mail($to, $subject, $HTMLmsg, $headers);
$g=mail("myemail@email.com",$subject,$HTMLmsg2,$headers2);
if($v) {
$_SESSION['ordersent']="Sent";
$ErrorMsg="";
//show confirmation page
//This is the part that does not seem to happen...
include("email.php");
if (isset($_GET['clear'])) {
$shield=$_GET['clear'];
if ($shield==$_SESSION['shield']) {
foreach($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
}
$_SESSION['cart_empty']=1;
$cart=array("desc" => "FootLog","qty" => "0", "price" => "19.95");
$_SESSION["Item1"]=$cart;
$cart=array("desc" => "BodyLog","qty" => "0", "price" => "19.95");
$_SESSION["Item2"]=$cart;
$cart=array("desc" => "FootMag","qty" => "0", "price" => "15.95");
$_SESSION["Item3"]=$cart;
$cart=array("desc" => "Foot Cream","qty" => "0", "price" => "29.95");
$_SESSION["Item4"]=$cart;
$cart=array("desc" => "ToesEase®","qty" => "0", "price" => "19.95");
$_SESSION["Item5"]=$cart;
$cart=array("desc" => "ToeSoak®","qty" => "0", "price" => "19.95");
$_SESSION["Item6"]=$cart;
$shield=md5(time());
$_SESSION['shield']=$shield;
}
}
else
{
$ErrorMsg="Email not sent, there was a problem";
}
}
}
else
{
$Item1=$_SESSION[Item1];
$Item2=$_SESSION[Item2];
$Item3=$_SESSION[Item3];
$Item4=$_SESSION[Item4];
$Item5=$_SESSION[Item5];
$Item6=$_SESSION[Item6];
I have done some programming in VB, but I am having difficulty in following the logic of this code. For example, in my mind, the $v variable, should 1) be set before the else, not after; and 2) should not receive the value of the email information before the if($v) statement. Am I missing something?
Any help would be appreciated