gpt4 book ai didi

php - 导调用子邮件提交转到 404 的复选框

转载 作者:行者123 更新时间:2023-12-04 05:11:48 27 4
gpt4 key购买 nike

我创建了一个表单(我已经省略了部分),它收集用户的复选框选择(通过 Wordpress 创建)并将结果通过电子邮件发送给我。

当我勾选硬件选择并提交电子邮件时,电子邮件可以正常发送,但是当我勾选任何附件并单击提交时,它会转到 404 页面。

谁能看到错误在哪里?我已经创建了两组复选框并以相同的方式产生了结果,只是看不出错误在哪里!

<form id="customisesystem" name="enquiry" method="POST" onSubmit="return formCheck(this);" action="<?php echo the_permalink(); ?>">
<div id="customise-area">
<?php $posts = get_field('options');
if( $posts ):
$items = 0;
foreach( $posts as $post): // variable must be called $post (IMPORTANT)
setup_postdata($post); ?>
<div class="custom-option">
<p><b>
<?php the_title(); ?>
</b></p>
<br />
<div>
<p><?php echo the_field('description'); ?></p>
</div>
<?php $counter = 1; while(the_repeater_field('images')): ?>
<?php if($counter <= 1) { ?>
<img width="180" height="136" src="<?php the_sub_field('image'); ?>" alt="<?php the_title(); ?>" />
<?php } ?>
<?php $counter++; endwhile; ?>
<p>
<input type="checkbox" name="hardware[]" value="<?php the_title(); ?>">
Select</p>
<div class="clear"></div>
</div>
<?php $items++; endforeach;
wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly
endif; ?>
</div>
<div id="customise-area">
<?php $posts = get_field('accessories');
if( $posts ):
$items = 0;
foreach( $posts as $post): // variable must be called $post (IMPORTANT)
setup_postdata($post); ?>
<div class="custom-option">
<p><b>
<?php the_title(); ?>
</b></p>
<br />
<div>
<p><?php echo the_field('description'); ?></p>
</div>
<?php $counter = 1; while(the_repeater_field('images')): ?>
<?php if($counter <= 1) { ?>
<img width="180" height="136" src="<?php the_sub_field('image'); ?>" alt="<?php the_title(); ?>" />
<?php } ?>
<?php $counter++; endwhile; ?>
<p>
<input type="checkbox" name="accessories[]" value="<?php the_title(); ?>">
Select</p>
<div class="clear"></div>
</div>
<?php $items++; endforeach;
wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly
endif; ?>
</div>
<? if(isset($_POST['submit'])) {

$to = "rob@domain.com";
$header = 'From: rob@domain.com';
$subject = "Domain: Quotation";
$enquiry_first_name = $_POST['enquiryfirstname'];
$enquiry_last_name = $_POST['enquirylastname'];
$enquiry_title = $_POST['enquirytitle'];
$enquiry_organisation = $_POST['enquiryorganisation'];
$enquiry_address = $_POST['enquiryaddress'];
$enquiry_country = $_POST['enquirycountry'];
$enquiry_email_address = $_POST['enquiryemailaddress'];
$enquiry_telephone = $_POST['enquirytelephone'];
$enquiry_additional_comments = $_POST['enquiryadditionalcomments'];
$enquiry_product = get_the_title();
if(!empty($_POST['hardware'])) {
foreach($_POST['hardware'] as $check) {
$hardwareresults .= $check."\n";
}
}
if(!empty($_POST['accessories'])) {
foreach($_POST['accessories'] as $test) {
$accessoriesresults .= $test."\n";
}
}

$body = "You have a quote request from the website:

Quotation:
$enquiry_product

Hardware:
$hardwareresults

Accessories:
$accessoriesresults

Name: $enquiry_title $enquiry_first_name $enquiry_last_name
Type of organisation: $enquiry_organisation
Address: $enquiry_address, $enquiry_country
E-Mail: $enquiry_email_address
Tel: $enquiry_telephone
Comments: $enquiry_additional_comments

Kind regards";

mail($to, $subject, $body, $header);

echo "Thank you for your enquiry.";

} ?>
</form>

最佳答案

我认为,这并没有直接对上面的代码做任何事情(或者错误只会被称为对影响此行为的 CMS 内部函数的约束函数调用),但我查看了发布的站点并尝试了.

当一切正常时,URL 与 404 错误相同(并且两者都输出 200 OK HTTP header 。这很奇怪,似乎这是您运行它的整个系统的问题。我已经采取了查看 404 页面,发现一些 PHP 错误,首先输出:

Warning: trim() expects parameter 1 to be string, array given in /home/teamwork/public_html/clients/rogue/wp-includes/query.php on line 1452

Warning: strip_tags() expects parameter 1 to be string, array given in /home/teamwork/public_html/clients/rogue/wp-includes/formatting.php on line 968



也许是调用了这些 WordPress 函数。您可以在确切地调用它们的位置/时间进行调试吗?

也许这会影响您的 CMS 进入错误模式而不是呈现正确的 View ?

关于php - 导调用子邮件提交转到 404 的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14834008/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com