第一次在这里发帖提问,对于我犯的任何错误都很抱歉!
我正在Wordpress中构建一个网站,该网站在主页上有一个联系表单。为了在有人填写电子邮件时发送电子邮件,我创建了一个自定义页面模板contact-success.php,在后端创建了一个页面并应用了模板:
<?php
/**
* Template Name: Contact Success
* Description: A Page Template shows contact success and sends email
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
使用基本邮件功能发送电子邮件:
<?php
$contact = $_POST['contact'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$query = $_POST['query'];
$message .= "The following form was submitted on the xxx website\n\n\n"; $message .= 'Name: ' . $contact . "\n\n";
$message .= 'Phone: ' . $phone . "\n\n";
$message .= 'E-Mail: ' . $email . "\n\n";
$message .= 'Query: ' . $query . "\n\n";
if(mail('xxx@xxx.co.uk', 'New Contact Submission from ' . $contact, $message)) {
echo('Successfully Sent');
} else {
echo('Message Failed');
}
?>
虽然表单从我的联系表单中正确提交并触发了电子邮件,但每当我访问其他应用了不同自定义页面模板的其他页面时,它似乎也会触发,location-results.php:
<?php
/**
* Template Name: Location Results
* Description: A Page Template that shows location results
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
关于我做错的任何想法?
非常感谢,如果我需要提供任何进一步的信息,请告诉我!