Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP代码停止代码如下_Php_Html - Fatal编程技术网

PHP代码停止代码如下

PHP代码停止代码如下,php,html,Php,Html,我有以下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'; $securim

我有以下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的意思,下面是一个查看源代码的示例。我想不出是什么问题。感谢您的帮助。

将模具换成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>');
为此:

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

谢谢“这确实有效,但现在它不能验证我的验证码。”亚历克斯基塔冯看我在回答中的编辑。我所做的是将代码的其余部分放在验证码if{}之后,放在一个else{}中,非常接近。它验证验证码并提交表单,但它确实会将我带到我已重定向到的感谢页面:$redirectURL=‘年度竞赛代表thankyou.php’@AlexKittavong你的意思是不带你去页面?但这可能是因为您没有对$URL进行任何操作。您只在其中设置了一个php文件名。但是你从来没有在你粘贴的代码中使用过这个变量。是的,对不起,它不会把我带到页面。在替换您发送给我的最后一段代码之前,&redirectURL确实将我带到了感谢页面。您需要调试代码:
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');
}