Hi PHP Experts.
Last day, i got my website new version up (from old xhtml to responsive website)
as i uploaded the new website live, i started getting dozens of form email in my email.
And it's really annoying, i got 250 blank emails in 24 hours, with 4 or 5 real filled form emails. So form PHP is working fine, but loads of blank emails.
I am a graphics designer, so totally novice in PHP, i am using below script from years, worked in website old, as well as new version of my website,
i also tried putting validation using DreamWeaver behaviors, which puts validation, i have checked,
but still getting blank form emails, what can be the reason.
PLEASE HELP..... It will be kind if someone can share workable easy validation script... thats easy to understand and edit.
Thanks in advance.
--------------------1 PHP File (contact.php)
<?
$mailto="
[email protected]";
$file="thanks.htm";
$pcount=0;
$gcount=0;
$subject = "Naming Mail from Enquiry Form";
$from="
[email protected]";
while (list($key,$val)=each($_POST))
{
$pstr = $pstr."$key : $val \n ";
++$pcount;
}
while (list($key,$val)=each($_GET))
{
$gstr = $gstr."$key : $val \n ";
++$gcount;
}
if ($pcount > $gcount)
{
$message_body=$pstr;
mail($mailto,$subject,$message_body,"From:".$from);
// #include("$file");
header('Location: thankyou.htm');
}
else
{
$message_body=$gstr;
mail($mailto,$subject,$message_body,"From:".$from);
// #include("$file");
header('Location: thankyou.htm');
}
?>
----------------------2 validation
<script type="text/javascript">
function change(val)
{
window.location = 'http://www.mydomainname.com/'+val;
}
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
</script>
---------------------- 3
<form action="http://www.yourdomainname.com/contactus.php" method="post" name="myForm" id="contactForm" onsubmit="MM_validateForm('name','','R','cell','','RisNum','email4','','RisEmail','nationality3','','R','company-details','','R');return document.MM_returnValue">
<div class="col-md-12">
<div class="form-group">
<label>1. Name</label>
<input name="name" type="text" id="name" class="form-control"/>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label> 2. Phone / Mobile</label>
<input name="cell" type="text" id="cell" class="form-control"/>
</div>
</div>
and so on more form fields.................................