gpt4 book ai didi

php - 将另一行添加到现有的 PHP 联系表单

转载 作者:行者123 更新时间:2023-11-28 00:35:41 24 4
gpt4 key购买 nike

我正在使用模板开发一个简单的单页网站。来自的联系人只有姓名电子邮件和邮件正文。我尝试添加号码。它显示在页面上,并且该行显示在电子邮件中,但该号码实际上并没有通过。

我复制并粘贴了其他数据点之一的现有代码,并更改了电话号码的 ID、类型等。

该页面在 test.wotactical.com 上可用

编辑:添加了 javascript 代码

PHP

<?php

// Put contacting email here
$php_main_email = "ffl@wotactical.com";
$php_sending_email = "contact@wotactical.com";

//Fetching Values from URL
$php_name = $_POST['ajax_name'];
$php_email = $_POST['ajax_email'];
$php_phone = $_POST['ajax_phone'];
$php_message = $_POST['ajax_message'];



//Sanitizing email
$php_email = filter_var($php_email, FILTER_SANITIZE_EMAIL);


//After sanitization Validation is performed
if (filter_var($php_email, FILTER_VALIDATE_EMAIL)) {


$php_subject = "New WOtactical contact form from " . $php_name;

// To send HTML mail, the Content-type header must be set
$php_headers = 'MIME-Version: 1.0' . "\r\n";
$php_headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$php_headers .= 'From:' . $php_sending_email. "\r\n"; // Sender's Email
$php_headers .= 'Cc:' . $php_email. "\r\n"; // Carbon copy to Sender

$php_template = '<div style="padding:50px;">Hello ' . $php_name . ',<br/>'
. 'Thank you for contacting us.<br/><br/>'
. '<strong style="color:#f00a77;">Name:</strong> ' . $php_name . '<br/>'
. '<strong style="color:#f00a77;">Number:</strong> ' . $php_phone . '<br/>'
. '<strong style="color:#f00a77;">Email:</strong> ' . $php_email . '<br/>'
. '<strong style="color:#f00a77;">Message:</strong> ' . $php_message . '<br/><br/>'
. 'This is a Contact Confirmation mail.'
. '<br/>'
. 'We will contact you as soon as possible .</div>';
$php_sendmessage = "<div style=\"background-color:#f5f5f5; color:#333;\">" . $php_template . "</div>";

// message lines should not exceed 70 characters (PHP rule), so wrap it
$php_sendmessage = wordwrap($php_sendmessage, 70);

// Send mail by PHP Mail Function
mail($php_main_email, $php_subject, $php_sendmessage, $php_headers);
echo "";


} else {
echo "<span class='contact_error'>* Invalid email *</span>";
}

?>

HTML

        <!-- CONTACT1 -->
<div class="edina_tm_section" id="contact">
<div class="edina_tm_main_title_holder_wrap contact">
<div class="number_wrap">
<span>06</span>
</div>
<div class="title_wrap">
<span>Contact Form</span>
</div>
</div>
<div class="edina_tm_contact_wrap">
<div class="short_info">
<div class="container">
<div class="subtitle">
<p class="wow fadeIn" data-wow-duration="1.2s">Special order, FFL Transfer, consignment or just have questions? We're happy to help.</p>
</div>
</div>
</div>
<div class="main_input_wrap">
<form action="/" method="post" class="contact_form" id="contact_form">
<div class="returnmessage" data-success="Your message has been received, We will contact you soon."></div>
<div class="empty_notice"><span>Please Fill Required Fields</span></div>
<div class="wrap wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.2s">
<input id="name" type="text" placeholder="Your Name">
</div>
<div class="wrap wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.4s">
<input id="email" type="text" placeholder="Your Email">
</div>
<div class="wrap wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.4s">
<input id="phone" type="tel" placeholder="Contact Number ex 123-456-7890" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
required>
</div>
<div class="wrap wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.6s">
<textarea id="message" placeholder="Type of inquiry, and/or details"></textarea>
</div>
<div class="edina_tm_button wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.8s">
<a id="send_message" href="#">Send Message</a>
</div>
</form>
</div>
</div>
</div>
<!-- /CONTACT1 -->

JavaScript

// -----------------------------------------------------
// ---------------- CONTACT FORM -----------------
// -----------------------------------------------------

function edina_tm_contact_form(){

"use strict";

jQuery(".contact_form #send_message").on('click', function(){

var name = jQuery(".contact_form #name").val();
var email = jQuery(".contact_form #email").val();
var phone = jQuery(".contact_form #phone").val();
var message = jQuery(".contact_form #message").val();
var subject = jQuery(".contact_form #subject").val();
var success = jQuery(".contact_form .returnmessage").data('success');

jQuery(".contact_form .returnmessage").empty(); //To empty previous error/success message.
//checking for blank fields
if(name===''||email===''||phone===''||message===''){

jQuery('div.empty_notice').slideDown(500).delay(2000).slideUp(500);
}
else{
// Returns successful data submission message when the entered information is stored in database.
jQuery.post("modal/contact.php",{ ajax_name: name, ajax_email: email, ajax_phone: phone, ajax_message:message, ajax_subject: subject}, function(data) {

jQuery(".contact_form .returnmessage").append(data);//Append returned message to message paragraph


if(jQuery(".contact_form .returnmessage span.contact_error").length){
jQuery(".contact_form .returnmessage").slideDown(500).delay(2000).slideUp(500);
}else{
jQuery(".contact_form .returnmessage").append("<span class='contact_success'>"+ success +"</span>");
jQuery(".contact_form .returnmessage").slideDown(500).delay(4000).slideUp(500);
}

if(data===""){
jQuery("#contact_form")[0].reset();//To reset form fields on success
}

});
}
return false;
});
}

最佳答案

我猜如果您可以删除您的正则表达式模式:

pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"

在这个元素中:

<div class="wrap wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.4s">
<input id="phone" type="tel" placeholder="Contact Number ex 123-456-7890" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
required>

并将其更改为:

<div class="wrap wow fadeIn" data-wow-duration="1.2s" data-wow-delay="0.4s">
<input id="phone" type="tel" placeholder="Contact Number ex 123-456-7890" required>

并测试它,它可能会起作用。或者您可以使用 888-888-8888 号码对其进行测试,看看它是否有效。

关于php - 将另一行添加到现有的 PHP 联系表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56410432/

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