PHP 联系表单 - 单个字段未填充



HTML 对于我的字段和联系人块,我的字段是名称,数字。电子邮件、主题、消息。我的所有字段都正常工作,提交后我完美地收到了电子邮件,除了数字字段,由于某种原因,该字段根本没有填充金额或任何值


<!-- contact section -->

<div class="container">
<div class="section-header">
<h2 class="wow fadeInDown animated">Contact Us</h2>
<p class="wow fadeInDown animated">Please fill in your contact details below and we will get back to you.<br>Alternatively contact us on: 031 464 4801 | 083 555 1202</p>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2 conForm">       
<form method="post" action="php/email.php" name="cform" id="cform" onsubmit="return checkform(this);">
<div id="message"></div>
<input name="name" id="name" type="text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12" placeholder="Your name..." >
<input name="cell" id="cell" type="number" class="col-xs-12 col-sm-12 col-md-12 col-lg-12" placeholder="Your Number..." >
<input name="email" id="email" type="email" class=" col-xs-12 col-sm-12 col-md-12 col-lg-12 noMarr" placeholder="Email Address..." >
<textarea name="comments" id="comments" cols="" rows="" class="col-xs-12 col-sm-12 col-md-12 col-lg-12" placeholder="Message..."></textarea>
<!-- START CAPTCHA -->

<br>
<div class="capbox">
<div id="CaptchaDiv"></div>
<div class="capbox-inner">
Type the above number:<br>
<input type="hidden" id="txtCaptcha">
<input type="text" name="CaptchaInput" id="CaptchaInput" size="15"><br>
</div>
</div>
<br><br>
<!-- END CAPTCHA -->
<input type="submit" id="submit" name="send" class="submitBnt" value="Send">
<div id="simple-msg"></div>
</form>
<script type="text/javascript">
// Captcha Script
function checkform(theform){
var why = "";
if(theform.CaptchaInput.value == ""){
why += "- Please Enter CAPTCHA Code.n";
}
if(theform.CaptchaInput.value != ""){
if(ValidCaptcha(theform.CaptchaInput.value) == false){
why += "- The CAPTCHA Code Does Not Match.n";
}
}
if(why != ""){
alert(why);
return false;
}
}
var a = Math.ceil(Math.random() * 9)+ '';
var b = Math.ceil(Math.random() * 9)+ '';
var c = Math.ceil(Math.random() * 9)+ '';
var d = Math.ceil(Math.random() * 9)+ '';
var e = Math.ceil(Math.random() * 9)+ '';
var code = a + b + c + d + e;
document.getElementById("txtCaptcha").value = code;
document.getElementById("CaptchaDiv").innerHTML = code;
// Validate input against the generated number
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('CaptchaInput').value);
if (str1 == str2){
return true;
}else{
return false;
}
}
// Remove the spaces from the entered and generated code
function removeSpaces(string){
return string.split(' ').join('');
}
</script>
</div>
</div>
</div>


这是将邮件,值和电子邮件格式推送到我的地址的PHP,同样,除了数字(单元格(字段之外,一切似乎都井井有条并且工作正常,无论您输入什么,都不会填充任何信息。


<?php
session_cache_limiter( 'nocache' );
$to = "bjorn@tech5.co.za";  //Recipient's E-mail
$headers  = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$message  = 'Name: ' . $_REQUEST['name'] . "<br>";
$message .= 'Number: ' . $_REQUEST['cell'] . "<br>";
$message .= 'Email: ' . $_REQUEST['email'] . "<br>";
$message .= $_REQUEST['comments'];

if (@mail($to, 'New Inquiry from Executive Plant Hire', $message, $headers))
{
mail('bjorn@tech5.co.za', 'New Inquiry from Executive Plant Hire', $message, $headers);
// Transfer the value 'sent' to ajax function for showing success message.
echo '<label class="lbl lbl-success">Your email has been sent successfully, we will be in touch</label>';
// header('Location: ../index.html');
}
else
{
// Transfer the value 'failed' to ajax function for showing error message.
echo '<label class="lbl lbl-warning">There was a problem sending you request, please contact us directly</label>';
}

?>

任何人都可以提供一些帮助或建议我可能做错了什么吗?我已经尝试了我能想到的一切,但似乎没有任何效果......任何帮助或建议将不胜感激。

谢谢。

@Bjorn,

您可以在此处看到,输入任何非数字字符(例如可能包含在电话号码中的符号(将使数字字段无效。

<input type="number" id="check">
<button type="button" onclick="console.log(document.getElementById('check').value)">Check</button>

最新更新