This question already has an answer here:
I have this PHP code:
<?php
$redirectURL = 'contests-representative-of-the-year-thankyou.php';
$email_to = 'alex@theadamgrp.com';
$subject = 'Submission Form';
#### DO NOT EDIT BELOW THIS LINE ####
require_once dirname(__FILE__) . '/securimage.php';
$securimage = new Securimage();
$captcha = (isset($_REQUEST['ct_captcha'])) ? $_REQUEST['ct_captcha'] :
'';
if ($securimage->check($captcha) == false) {
die ('<p style="margin:30px 0 0 0; font-weight:bold; font-size:16px;">Invalid security code entered. Please <a href="javascript:history.go(-1);">click here</a> to go back.</p>');
}
$message = 'This form submission was received at '.date('n/j/Y g:i A').': '."
";
foreach ($_POST as $key=>$value){
$message .= "
".str_replace('_', ' ', $key).":
".$value;
}
$message .= "
IP: ".$_SERVER['REMOTE_ADDR'];
mail($email_to, $subject, $message, 'From: no-reply@email.com');
?>
When I insert this into my web page, it "deletes" the rest of my code below. I'm suppose to have a footer below it with links and everything. This is what I have below it:
</div>
</div>
<?php include("subpage-bar.php"); ?>
</div>
</div>
</div>
<?php include("footer.php"); ?>
</body>
Is there any reason why my PHP code above would delete everything else I have coded below it? Here is a link to view the source, if you want to visually see what O mean. I can't figure out what the problem is. Any help is appreciated.
</div>
change die()
into echo
So change
die ('<p style="margin:30px 0 0 0; font-weight:bold; font-size:16px;">Invalid security code entered. Please <a href="javascript:history.go(-1);">click here</a> to go back.</p>');
into
echo '<p style="margin:30px 0 0 0; font-weight:bold; font-size:16px;">Invalid security code entered. Please <a href="javascript:history.go(-1);">click here</a> to go back.</p>';
(so echo without the parens ()
)
edit
For the working catha change this:
if ($securimage->check($captcha) == false) {
die ('<p style="margin:30px 0 0 0; font-weight:bold; font-size:16px;">Invalid security code entered. Please <a href="javascript:history.go(-1);">click here</a> to go back.</p>');
}
$message = 'This form submission was received at '.date('n/j/Y g:i A').': '."
";
foreach ($_POST as $key=>$value){
$message .= "
".str_replace('_', ' ', $key).":
".$value;
}
$message .= "
IP: ".$_SERVER['REMOTE_ADDR'];
mail($email_to, $subject, $message, 'From: no-reply@email.com');
into this:
if ($securimage->check($captcha) == false) {
echo '<p style="margin:30px 0 0 0; font-weight:bold; font-size:16px;">Invalid security code entered. Please <a href="javascript:history.go(-1);">click here</a> to go back.</p>';
} else {
$message = 'This form submission was received at '.date('n/j/Y g:i A').': '."
";
foreach ($_POST as $key=>$value){
$message .= "
".str_replace('_', ' ', $key).":
".$value;
}
$message .= "
IP: ".$_SERVER['REMOTE_ADDR'];
mail($email_to, $subject, $message, 'From: no-reply@email.com');
}