-3

我有这个 PHP 代码:

<?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').': '."\n\n";
foreach ($_POST as $key=>$value){
    $message .= "\n\n".str_replace('_', ' ', $key).": \n".$value;
}

$message .= "\n\nIP: ".$_SERVER['REMOTE_ADDR'];
mail($email_to, $subject, $message, 'From: no-reply@email.com');
?>

当我将它插入我的网页时,它会“删除”我下面的其余代码。我想它下面有一个带有链接和所有内容的页脚。这就是我下面的内容:

</div>
</div>
<?php include("subpage-bar.php"); ?>
</div>
</div>
</div>
<?php include("footer.php"); ?>
</body>

为什么我上面的 PHP 代码会删除我在它下面编码的所有其他内容,有什么理由吗?如果您想直观地了解 O 的含义,这里是查看源代码的链接。我无法弄清楚问题是什么。任何帮助表示赞赏。

4

1 回答 1

1

变成die()_echo

所以改变

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>');

进入

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>';

(所以没有括号的回声()

编辑

对于工作 catha 改变这个:

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').': '."\n\n";
foreach ($_POST as $key=>$value){
    $message .= "\n\n".str_replace('_', ' ', $key).": \n".$value;
}

$message .= "\n\nIP: ".$_SERVER['REMOTE_ADDR'];
mail($email_to, $subject, $message, 'From: no-reply@email.com');

进入这个:

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').': '."\n\n";
    foreach ($_POST as $key=>$value){
        $message .= "\n\n".str_replace('_', ' ', $key).": \n".$value;
    }

    $message .= "\n\nIP: ".$_SERVER['REMOTE_ADDR'];
    mail($email_to, $subject, $message, 'From: no-reply@email.com');
}
于 2013-04-10T19:39:12.620 回答