Contact form problems
Posted: Tue Nov 10, 2009 8:42 am
Hi, I am moving a website from a linux server to windows server with a newer version of PHP on. I am having problems getting a contact form to work on the new server. The new server is running PHP version 5.2.10 on windows server 2008 with IIS 7. PHP is installed and working fine with other sites.
When I press submit on this contact form I get the following error-
Can anyone help please? Thanks in advance
When I press submit on this contact form I get the following error-
The code for the file is -PHP Notice: Undefined index: Refference2Name in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 33 PHP Notice: Undefined variable: Name in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 46 PHP Notice: Undefined variable: Email in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 47 PHP Notice: Undefined variable: message in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 48 PHP Notice: Undefined variable: Name in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 52 PHP Notice: Undefined variable: Email in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 53 PHP Notice: Undefined variable: message in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 54 PHP Notice: Undefined variable: Surname in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 270 PHP Warning: mail() [function.mail]: SMTP server response: 501 5.1.7 Invalid address in E:\Websites\website\public_html\_includes\contact-form-open-account.php on line 272
Code: Select all
<?php
if (isset($_POST["op"]) && ($_POST["op"]=="send")) {
/******** START OF CONFIG SECTION *******/
$sendto = "enquiries@domain.com";
$subject = "Domain Website Enquiry - Contact Form";
$from = "Company Name";
$companylogo = "<a href='http://www.companylogo.com'><img src='http://www.companylogo.com/images/powered-by-email-logo.jpg' width='191' height='39' alt='Powered by Company' border='0' /></a>";
// Select if you want to check form for standard spam text
$SpamCheck = "Y"; // Y or N
$SpamReplaceText = "*content removed*";
// Error message prited if spam form attack found
$SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.</font><br><b>Your IP Number of <b>".getenv("REMOTE_ADDR")."</b> has been logged.</b></p>";
/******** END OF CONFIG SECTION *******/
$companyname = $_POST['companyname']; // Form element
$address = $_POST['address']; // Form element
$Tel = $_POST['Tel']; // Form element
$Fax = $_POST['Fax']; // Form element
$RegisteredOffice = $_POST['RegisteredOffice']; // Form element
$CompanyNo = $_POST['CompanyNo']; // Form element
$VATNo = $_POST['VATNo']; // Form element
$Directors = $_POST['Directors']; // Form element
$YearsTrading = $_POST['YearsTrading']; // Form element
$Contact = $_POST['Contact']; // Form element
$CreditLimit = $_POST['CreditLimit']; // Form element
$Refference1Name = $_POST['Refference1Name']; // Form element
$Refference1Contact = $_POST['Refference1Contact']; // Form element
$Refference1Tel = $_POST['Refference1Tel']; // Form element
$Refference1Fax = $_POST['Refference1Fax']; // Form element
$Refference2Name = $_POST['Refference2Name']; // Form element
$Refference2Contact = $_POST['Refference2Contact']; // Form element
$Refference2Tel = $_POST['Refference2Tel']; // Form element
$Refference2Fax = $_POST['Refference2Fax']; // Form element
$Refference3Name = $_POST['Refference3Name']; // Form element
$Refference3Contact = $_POST['Refference3Contact']; // Form element
$Refference3Tel = $_POST['Refference3Tel']; // Form element
$Refference3Fax = $_POST['Refference3Fax']; // Form element
if ($SpamCheck == "Y") {
// Check for Website URL's in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
if (preg_match("/http/i", "$Name")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$Email")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();}
// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
$pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string
$Name = preg_replace($pattern, "", $Name);
$Email = preg_replace($pattern, "", $Email);
$message = preg_replace($pattern, "", $message);
// Check for the injected headers from the spammer attempt
// This will replace the injection attempt text with the string you have set in the above config section
$find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
$Email = preg_replace($find, "$SpamReplaceText", $Email);
$Name = preg_replace($find, "$SpamReplaceText", $Name);
$message = preg_replace($find, "$SpamReplaceText", $message);
// Check to see if the fields contain any content we want to ban
if(stristr($Name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
// Do a check on the send email and subject text
if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
}
// HTML Email Code
$Emailcontent = '
<html>
<body>
<table cellpadding="0" cellspacing="0" width="100%" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#7F7F7F; line-height:14px;">
<tr valign="top">
<td valign="top">'.$companylogo.'</td>
</tr>
<tr valign="top">
<td valign="top">
<br /><strong>A new user has submitted the following enquiry from your website:</strong><br /><br />
</td>
</tr>
<tr valign="top">
<td><strong>Company Details</strong></td>
</tr>
<tr valign="top">
<td>
Company Name:
'.$companyname.'
</td>
</tr>
<tr valign="top">
<td>
Address:
'.$address.'
</td>
</tr>
<tr valign="top">
<td>
Telephone No:
'.$Tel.'
</td>
</tr>
<tr>
<td>
Fax No:
'.$Fax.'
</td>
</tr>
<tr valign="top">
<td>
Registered Office:
'.$RegisteredOffice.'
</td>
</tr>
<tr valign="top">
<td>
Company Registration No:
'.$CompanyNo.'
</td>
</tr>
<tr>
<td>
VAT Registration No:
'.$VATNo.'
</td>
</tr>
<tr valign="top">
<td>
Names of Directors:
'.$Directors.'
</td>
</tr>
<tr valign="top">
<td>
Years of Trading:
'.$YearsTrading.'
</td>
</tr>
<tr valign="top">
<td>
Contact:
'.$Contact.'
</td>
</tr>
<tr>
<td>
Credit Limit required: £
'.$CreditLimit.'
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<br />
<table cellpadding="0" cellspacing="0" width="100%" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#7F7F7F; line-height:14px;">
<tr valign="top">
<td><strong>Trade References</strong></td>
</tr>
<tr valign="top">
<td>
Reference 1 - Name & Address:
'.$Refference1Name.'
</td>
</tr>
<tr valign="top">
<td>
Contact Name:
'.$Refference1Contact.'
</td>
</tr>
<tr>
<td>
Tel:
'.$Refference1Tel.'
</td>
</tr>
<tr>
<td>
Fax:
'.$Refference1Fax.'
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr valign="top">
<td>
Reference 2 - Name & Address:
'.$Refference2Name.'
</td>
</tr>
<tr valign="top">
<td>
Contact Name:
'.$Refference2Contact.'
</td>
</tr>
<tr>
<td>
Tel:
'.$Refference2Tel.'
</td>
</tr>
<tr>
<td>
Fax:
'.$Refference2Fax.'
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr valign="top">
<td>
Reference 3 - Name & Address:
'.$Refference3Name.'
</td>
</tr>
<tr valign="top">
<td>
Contact Name:
'.$Refference3Contact.'
</td>
</tr>
<tr>
<td>
Tel:
'.$Refference3Tel.'
</td>
</tr>
<tr>
<td>
Fax:
'.$Refference3Fax.'
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
';
// Check the email address enmtered matches the standard email address format
if(isset($_POST["submit"])){
$error_msg='';
// Captcha security code
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
// do nothing or print blank error code
} else {
$error_msg.= '<span style="color:#878787;"><strong>* Incorrect security code!</strong><br /> Please ensure you type the security code exactly how it appears<br /></span>';
}
// display error message if any, if not, proceed to other processing
if($error_msg!=''){
echo "<h2>Error!</h2>Your enquiry was not submitted due to the following errors:<br /><br />";
echo $error_msg."<br />";
echo "<p><a href='javascript: history.go(-1)'>< Back</a></p>"; // other process here
}
// Sends out the email or will output the error message
elseif (mail($sendto, $subject, $Emailcontent,
"To: Company<enquiries@domain.com>\n" .
"From: ".$Name." ".$Surname."<".$companyname.">\n" .
"MIME-Version: 1.0\n" .
"Content-type: text/html; charset=iso-8859-1")) {
echo "<h1>Thankyou!</h1>Your enquiry has been submitted";
}
}
} else {
?>
<form name="contactform" method="post" class="contact-form-open-account" action="">
<input name="op" type="hidden" value="send" />
<table cellpadding="0" cellspacing="0" width="100%" class="new_account">
<tr valign="top">
<td><h2>Company Details</h2></td>
</tr>
<tr valign="top">
<td id="theCompany">
<label for="companyname">Company Name in full:</label>
<input type="text" maxlength="100" id="companyname" name="companyname" class="account_input_field" tabindex="" style="width:458px;" align="left" />
</td>
</tr>
<tr valign="top">
<td id="theAddress">
<label for="address">Address:</label>
<input type="text" maxlength="100" id="address" name="address" class="account_input_field" tabindex="" style="width:534px;" />
</td>
</tr>
<tr valign="top">
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td id="theTel">
<label for="Tel">Telephone No:</label>
<input type="text" maxlength="25" id="Tel" name="Tel" class="account_input_field" tabindex="" style="width:225px;" />
</td>
<td id="theFax">
<label for="Fax">Fax No:</label>
<input type="text" maxlength="25" id="Fax" name="Fax" class="account_input_field" tabindex="" style="width:224px;" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td>
<label for="RegisteredOffice">Registered Office (if different):</label>
<input type="text" id="RegisteredOffice" name="RegisteredOffice" class="account_input_field" tabindex="" style="width:421px;" />
</td>
</tr>
<tr valign="top">
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td id="theCompanyNumber">
<label for="CompanyNo">Company Registration No:</label>
<input type="text" maxlength="25" id="CompanyNo" name="CompanyNo" class="account_input_field" tabindex="" style="width:157px;" />
</td>
<td id="theVATNumber">
<label for="VATNo">VAT Registration No:</label>
<input type="text" maxlength="25" id="VATNo" name="VATNo" class="account_input_field" tabindex="" style="width:156px;" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top" id="theDirectors">
<td>
<label for="Directors">Names of Directors:</label>
<input type="text" id="Directors" name="Directors" class="account_input_field" tabindex="" style="width:473px;" />
</td>
</tr>
<tr valign="top" id="theYearsTrading">
<td>
<label for="YearsTrading">Years of Trading:</label>
<input type="text" id="YearsTrading" name="YearsTrading" class="account_input_field" tabindex="" style="width:490px;" />
</td>
</tr>
<tr valign="top">
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td id="theContact">
<label for="Contact">Contact:</label>
<input type="text" maxlength="25" id="Contact" name="Contact" class="account_input_field" tabindex="" style="width:201px;" />
</td>
<td id="theCreditLimit">
<label for="CreditLimit">Credit Limit required: £</label>
<input type="text" maxlength="25" id="CreditLimit" name="CreditLimit" class="account_input_field" tabindex="" style="width:200px;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<br />
<table cellpadding="0" cellspacing="0" width="100%" class="new_account">
<tr valign="top">
<td><h2>Trade References</h2></td>
</tr>
<tr valign="top" id="theRefference1Name">
<td>
<label for="Refference1Name">Reference 1 - Name & Address:</label>
<input type="text" id="Refference1Name" name="Refference1Name" class="account_input_field" tabindex="" style="width:409px;" />
</td>
</tr>
<tr valign="top">
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td id="theRefference1Contact">
<label for="Refference1Contact">Contact Name:</label>
<input type="text" maxlength="25" id="Refference1Contact" name="Refference1Contact" class="account_input_field" tabindex="" style="width:195px;" />
</td>
<td id="theRefference1Tel">
<label for="Refference1Tel">Tel:</label>
<input type="text" maxlength="25" id="Refference1Tel" name="Refference1Tel" class="account_input_field" tabindex="" style="width:120px;" />
</td>
<td id="theRefference1Fax">
<label for="Refference1Fax">Fax:</label>
<input type="text" maxlength="25" id="Refference1Fax" name="Refference1Fax" class="account_input_field" tabindex="" style="width:120px;" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top" id="theRefference2Name">
<td>
<label for="Refference2Name">Reference 2 - Name & Address:</label>
<input type="text" id="Refference1Name" name="Refference1Name" class="account_input_field" tabindex="" style="width:409px;" />
</td>
</tr>
<tr valign="top">
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td id="theRefference2Contact">
<label for="Refference2Contact">Contact Name:</label>
<input type="text" maxlength="25" id="Refference2Contact" name="Refference2Contact" class="account_input_field" tabindex="" style="width:195px;" />
</td>
<td id="theRefference2Tel">
<label for="Refference2Tel">Tel:</label>
<input type="text" maxlength="25" id="Refference2Tel" name="Refference2Tel" class="account_input_field" tabindex="" style="width:120px;" />
</td>
<td id="theRefference2Fax">
<label for="Refference2Fax">Fax:</label>
<input type="text" maxlength="25" id="Refference2Fax" name="Refference2Fax" class="account_input_field" tabindex="" style="width:120px;" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top" id="theRefference3Name">
<td>
<label for="Refference3Name">Reference 3 - Name & Address:</label>
<input type="text" id="Refference3Name" name="Refference3Name" class="account_input_field" tabindex="" style="width:409px;" />
</td>
</tr>
<tr valign="top">
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td id="theRefference3Contact">
<label for="Refference3Contact">Contact Name:</label>
<input type="text" maxlength="25" id="Refference3Contact" name="Refference3Contact" class="account_input_field" tabindex="" style="width:195px;" />
</td>
<td id="theRefference3Tel">
<label for="Refference3Tel">Tel:</label>
<input type="text" maxlength="25" id="Refference3Tel" name="Refference3Tel" class="account_input_field" tabindex="" style="width:120px;" />
</td>
<td id="theRefference3Fax">
<label for="Refference3Fax">Fax:</label>
<input type="text" maxlength="25" id="Refference3Fax" name="Refference3Fax" class="account_input_field" tabindex="" style="width:120px;" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<br />
<table cellpadding="0" cellspacing="0" width="100%" class="new_account">
<tr valign="top" id="theSecurity">
<td align="center">
<br /><label for="security_code"><strong>Security Code</strong>:</label> Please enter the code<br /><br />
<img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" align="absmiddle" />
<input id="security_code" name="security_code" type="text" class="security_field" tabindex="" />
</td>
</tr>
<tr valign="top">
<td align="center"><input type="submit" align="top" alt="Submit" name="submit" tabindex="" value="Submit" class="bf_submit" /></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
var theCompany = new Spry.Widget.ValidationTextField("theCompany", "none", {useCharacterMasking:true, validateOn:["change"]});
var theAddress = new Spry.Widget.ValidationTextField("theAddress", "none", {useCharacterMasking:true, validateOn:["change"]});
var theTel = new Spry.Widget.ValidationTextField("theTel", "none", {useCharacterMasking:true, validateOn:["change"]});
var theFax = new Spry.Widget.ValidationTextField("theFax", "none", {useCharacterMasking:true, validateOn:["change"]});
var theCompanyNumber = new Spry.Widget.ValidationTextField("theCompanyNumber", "none", {useCharacterMasking:true, validateOn:["change"]});
var theVATNumber = new Spry.Widget.ValidationTextField("theVATNumber", "none", {useCharacterMasking:true, validateOn:["change"]});
var theDirectors = new Spry.Widget.ValidationTextField("theDirectors", "none", {useCharacterMasking:true, validateOn:["change"]});
var theYearsTrading = new Spry.Widget.ValidationTextField("theYearsTrading", "none", {useCharacterMasking:true, validateOn:["change"]});
var theContact = new Spry.Widget.ValidationTextField("theContact", "none", {useCharacterMasking:true, validateOn:["change"]});
var theCreditLimit = new Spry.Widget.ValidationTextField("theCreditLimit", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference1Name = new Spry.Widget.ValidationTextField("theRefference1Name", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference1Contact = new Spry.Widget.ValidationTextField("theRefference1Contact", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference1Tel = new Spry.Widget.ValidationTextField("theRefference1Tel", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference1Fax = new Spry.Widget.ValidationTextField("theRefference1Fax", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference2Name = new Spry.Widget.ValidationTextField("theRefference2Name", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference2Contact = new Spry.Widget.ValidationTextField("theRefference2Contact", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference2Tel = new Spry.Widget.ValidationTextField("theRefference2Tel", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference2Fax = new Spry.Widget.ValidationTextField("theRefference2Fax", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference3Name = new Spry.Widget.ValidationTextField("theRefference3Name", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference3Contact = new Spry.Widget.ValidationTextField("theRefference3Contact", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference3Tel = new Spry.Widget.ValidationTextField("theRefference3Tel", "none", {useCharacterMasking:true, validateOn:["change"]});
var theRefference3Fax = new Spry.Widget.ValidationTextField("theRefference3Fax", "none", {useCharacterMasking:true, validateOn:["change"]});
var theSecurity = new Spry.Widget.ValidationTextField("theSecurity", "none", {useCharacterMasking:true, validateOn:["change"]});
//-->
</script>
<?php
}
?>