Hello all,
My client wanted me to add a pop up notification for mandatory fields in his form which i did, see here: Property & Mortgage Group (click on contact) But now when i test the form I recieve the test email but without any of the correct information.
It reads:
Subject: Unknown
From: Unknown
And the email thinks it’s spam. It says: This message looks suspicious to our SmartScreen filters.
Can anyone help please?
Thank you.
This is my JS:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.form.formName.value=="Your name") {
themessage = themessage + " - Your Name";
}
if (document.form.formSubject.value=="Subject") {
themessage = themessage + " - Subject";
}
if (document.form.message.value=="Type message here") {
themessage = themessage + " - Your Message";
}
if (document.form.formPhone.value=="Your Contact Number") {
themessage = themessage + " - Your Phone";
}
if (document.form.formEmail.value=="Your Email") {
themessage = themessage + " - Your Email";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
// End -->
</script>
This is my HTML form:
<div class="flash_form newform">
<form name=form action="sendForm.php" method="post" enctype="multipart/form-data">
<input type=text name="formName" class="formText" value="Your name" onFocus="if(this.value=='Your name')this.value='';" onFocus="if(this.value=='Your name')this.value='';" onBlur="if(this.value=='')this.value='Your name';"/>
<input type=text name="formSubject" class="formText" value="Subject" onFocus="if(this.value=='Subject')this.value='';" onFocus="if(this.value=='Subject')this.value='';" onBlur="if(this.value=='')this.value='Subject';"/>
<input type=text name="message" class="formText" value="Type message here" onFocus="if(this.value=='Type message here')this.value='';" onFocus="if(this.value=='Type message here')this.value='';" onBlur="if(this.value=='')this.value='Type message here';" style="width:350px; height:200px; line-height:50px;"/>
<input type=text name="formPhone" class="formText" value="Your Contact Number" onFocus="if(this.value=='Your Contact Number')this.value='';" onFocus="if(this.value=='Your Contact Number')this.value='';" onBlur="if(this.value=='')this.value='Your Contact Number';"/>
<input type=text name="formEmail" class="formText" value="Your Email" onFocus="if(this.value=='Your Email')this.value='';" onFocus="if(this.value=='Your Email')this.value='';" onBlur="if(this.value=='')this.value='Your Email';"/><BR><BR>
<input type=button value="Submit Request" onclick="verify();">
</form>
</div>
This is the PHP:
<?
$to = "rossnaumov@hotmail.com";
$from = "$formEmail";
$subject = "Message from $formName";
$contents = "$subject \
\
$message \
\
$from \
\
$formPhone";
$from_header = "From: $formEmail";
$returnPage = "thankyou_email.html";
if($contents != "")
{
//send mail - $subject & $contents come from surfer input
mail($to, $subject, $contents, $from_header);
// redirect back to url visitor came from
header("Location: $returnPage");
}
else
{
print("<HTML><BODY>Error, no comments were submitted!");
print("</BODY></HTML>");
}
?>