留言form
<div class="contact_form">
<!-- <h3 class="pro-sec-tit"><span>Inquiry</span> </h3> -->
<script type="text/javascript">
function check(form) {undefined
if(form.email.value=='') {undefined
alert("input email ");
form.email.focus();
return false;
}
if(form.content.value==''){undefined
alert("input content");
form.content.focus();
return false;
}
document.form.submit();
}
</script>
<form id="form" name="form" method="post" action="/fedback/mail/tomail.php" onsubmit="return check(this)">
<div class="column">
<input type="text" maxlength="25" name="name" class="fl" placeholder="Your Name" />
</div>
<div class="column">
<input type="text" maxlength="25" name="email" class="fr" placeholder="Your E-mail(*)" />
</div>
<div class="column">
<input type="text" oninput="value=value.replace(/[^\w+()]/g,'');" maxlength="20" name="phone" class="fl" placeholder="Your WhatsApp" />
</div>
<!-- <div class="column">
<input type="text" name="country" class="fr" placeholder="Your Country/Region" />
</div> -->
<div class="column">
<input type="text" maxlength="25" name="company" class="fl" placeholder="Your Company" />
</div>
<!-- <div class="column">
<input type="text" name="capacity" class="fr" placeholder="Capacity" />
</div> -->
<div id="sub_txt" class="column">
<textarea name="content" cols="40" rows="10" maxlength="300" aria-Required="true" aria-invalid="false" placeholder="Your Message: (*)Tips,Please tell us your detailed needs, such as machine names, capacities, etc."></textarea>
</div>
<div id="sub_button" class="form-control">
<!-- <span class="wp-not-Robots"> I'm not Robots verify-input: "yunda" </span> -->
<!-- <span class="wp-not-Robots-i"> <input type="text" name="yzm" placeholder="I'm not Robots verify-input: yunda " /> </span> -->
<button type="submit" class="liuyan-submit"> Send inquiry now</button>
</div>
<div class="column-s"> <input type="radio" name=" " checked="checked"> <span class="wpcf7-list-item-label">I have read and agree to the YunDa <a href="/privacy-policy/">Privacy Policy *</a></span>
</div>
<input type="hidden" name="lang" value="en" />
<input type="hidden" name="ip" value=" " />
<input type="hidden" name="fdtitle" value=" " />
<input type="hidden" name="id" value="6liuyan" />
</form>
</div>
Tomail
<head>
<!-- Google tag (gtag.js) -->
<!-- Google Tag Manager -->
<!-- End Google Tag Manager -->
<?php
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:OPTIONS, GET, POST'); // 允许option,get,post请求
header('Access-Control-Allow-Headers:*');
// header('Access-Control-Allow-Headers:x-requested-with, content-type'); // 允许x-requested-with请求头
$url_referer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : '';
$http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
header('Content-Type: text/html; charset=UTF-8');
?>
</head>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$title = isset($_POST['title']) ? $_POST['title'] : null;
$username = isset($_POST['name']) ? $_POST['name'] : null;
$useremail = isset($_POST['email']) ? $_POST['email'] : null;
$userinquiry = isset($_POST['content']) ? $_POST['content'] : null;
$userphone = isset($_POST['phone']) ? $_POST['phone'] : null;
$usercountry = isset($_POST['country']) ? $_POST['country'] : null;
$useraddress = isset($_POST['address']) ? $_POST['address'] : null;
$fromcompany = isset($_POST['from_company']) ? $_POST['from_company'] : null;
$company = isset($_POST['company']) ? $_POST['company'] : null;
$materials = isset($_POST['materials']) ? $_POST['materials'] : null;
$application = isset($_POST['application']) ? $_POST['application'] : null;
$capacity = isset($_POST['capacity']) ? $_POST['capacity'] : null;
$products = isset($_POST['products']) ? $_POST['products'] : null;
$useplace = isset($_POST['useplace']) ? $_POST['useplace'] : null;
$imtype = isset($_POST['imtype']) ? $_POST['imtype'] : null;
$imvalue = isset($_POST['imvalue']) ? $_POST['imvalue'] : null;
$timezone_offset = isset($_POST['timezone_offset']) ? $_POST['timezone_offset'] : null;
$id = isset($_POST['id']) ? $_POST['id'] : null;
$servertime= date('Y年m月d日 H:i:s'); //date("Y-m-d" H:i:s); date('Y年m月d日 H:i:s');
//额外的字段可以在这儿添加
$metadata = array(
'materials' => $materials,
'application' => $application,
'capacity' => $capacity,
'products' => $products,
'useplace' => $useplace,
'imtype' => $imtype,
'imvalue' => $imvalue,
'company' => $company,
'timezone_offset' => $timezone_offset
);
} ;
$ip = $_SERVER['REMOTE_ADDR']."<br>".$_SERVER['HTTP_X_FORWARDED_FOR']."<br>".$_SERVER['HTTP_CLIENT_IP'] ;
//$title, $username, $useremail, $userinquiry, $userphone, $usercountry, $useraddress, $fromcompany, date('Y-m-d H:i:s') ."<hr><br>".
$string="name:".$username."<Br>E-mail:".$useremail."<Br> inquiry:".$userinquiry."<Br> company:".$company."<Br> Link:".$url_referer."<Br>" .$http_referer."<Br>Whatsapp:" .$userphone."<Br>country:" .$usercountry ."<Br>" .$ip."<Br>".$servertime ." $id " ;
//echo "$string";
?>
<body>
<style type="text/css">
body { width:62% ; float: left;}
.box {
margin: 18% auto;
_margin: 10% auto;
border: 1px solid #ccc;
border-radius: 10px;
width: 50%;
padding: 30px;
}
.box h3 {
font-size: 26px;
line-height: 55px;
text-align: center;
font-weight: 700;
color: #cd0202;
font-size: 40px;
font-weight: normal;
text-align: center;
margin-top: 15px;
}
.box p {
margin-top: 15px;
color: #333;
font-size: 19px;
}
</style>
<div class="box">
<?php require 'ip.php'; ?>
<?php
require 'mail.php';
?>
<img decoding="async" width="605" height="" src=" /fedback/mail/wechat.png" alt="wechat" >
<p>Your message has been successfully submitted and we will get back to you within 24 hours. Please check your email. </p>
<div class="btn"><a href="javascript:history.go(-1);">Return</a><a href="javascript:history.go(-1);">Other Products</a></div>
</div>
</body>
辨别过滤垃圾留言
<?php
//开始判断是 为空
// if
// ( $userphone == 'yunda' )
// {
// echo "<h3> input phone number <br>";
// echo " <a href=" .$http_referer . ">Go back </a></h3>" ;
// exit() ;
// }
// else
$iqstr=strlen ($userinquiry) ; // echo $iqstr ;
if
( $iqstr >200 )
{
echo "<h3> You are robot, CLOSE</h3>";
echo " <a href=" .$http_referer . ">Go back </a> </h3>" ;
exit() ;
}
else if($userinquiry == '') //开始判断是够为空
{
echo "<h3> input message <br> ";
echo " <a href=" .$http_referer . ">Go back </a> </h3>" ;
exit() ;
}
else if($company =='google') {
echo $company ."<h3> CLOSE</h3>";
echo " <h3> <a href=" .$http_referer . ">Go back </a> </h3>" ;
exit() ;
}
?>
<?php
// 判断e mail
// $email = "example@example.com";
$pattern = "/^[\w\-]+(\.[\w\-]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*(\.[a-zA-Z]{2,})$/";
if (!preg_match($pattern, $useremail )) {
echo "<h3>Invalid email format</h3>";
echo " <h3> <a href=" .$http_referer . ">Go back </a> </h3>" ;
exit() ;
} else {
// echo "Valid email format";
}
?>
mail 引入发送邮箱的类 PHPmailer.