New to PHP need help with form Process!

Hi,
IMPORTANT!! PLEASE HELP!!!
I’m new to PHP and I need some help with a form I’m doing for a customer. Several fields need to be validated. I grabbed some code online to get me started, but have have to edit it. I’m not sure if it is the PHP that is causing it to not work or the js(validation). most all of the validation code works. The only thing that messes up is instead of it reading the field Company as Company it reads it as Your Message although i clearly labeled that field as id=“Company”. Other than that the validation is working but when i go to submit I get this error message:

[COLOR=“Red”]The page cannot be displayed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

Please try the following:

Contact the Web site administrator if you believe that this request should be allowed.
Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.

HTTP Error 405 - The HTTP verb used to access this page is not allowed.
Internet Information Services (IIS)

Technical Information (for support personnel)

Go to Microsoft Product Support Services and perform a title search for the words HTTP and 405.
Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Setting Application Mappings, Securing Your Site with Web Site Permissions, and About Custom Error Messages.

[/COLOR]

So Please help me here is the PHP I’m using (free_process.php):
[COLOR=“Blue”]<?php

if(isset($_POST

[‘Email_Address’])) {

include 'free_settings.php';

function died($error) 

{
echo "Sorry, but there were error(s) found with the form you submitted. ";

echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;";
	echo $error."&lt;br /&gt;&lt;br /&gt;";


echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;";
	die();
}

if(!isset($_POST['First_Name']) ||
	!isset($_POST['Last_Name']) ||

!isset($_POST[‘Company’]) ||
!isset($_POST[‘Add_1’]) ||
!isset($_POST

[‘Add_2’]) ||
!isset($_POST[‘City’]) ||
!isset($_POST[‘State’]) ||

!isset($_POST['Zip']) ||
	!isset($_POST['Country']) ||
	!

isset($_POST[‘Email_Address’]) ||
!isset($_POST[‘Telephone’])) {
died

(‘We are sorry, but there appears to be a problem with the form you submitted.’);
}

$first_name = $_POST['First_Name']; // required
$last_name = $_POST

[‘Last_Name’]; // required
$email_from = $_POST[‘Email_Address’]; // required

$telephone = $_POST[‘Telephone_Number’]; // not required
$company = $_POST[‘Company’];

// required
$add_1 = $_POST[‘Add_1’]; // required
$add_2 = $_POST[‘Add_2’]; // not

required
$city = $_POST[‘City’]; // required
$state = $_POST[‘State’]; // required

$zip = $_POST[‘Zip’]; // required
$country = $_POST[‘Country’]; // required

$error_message = “”;
$email_exp = ‘/[1]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/’;

if(preg_match($email_exp,$email_from)==0) {
$error_message .= 'The Email Address you

entered does not appear to be valid.<br />';
}
if(strlen($first_name) < 2) {

$error_message .= ‘Your Name does not appear to be valid.<br />’;
}
if(strlen($last_name)

< 2) {
$error_message .= ‘Your Name does not appear to be valid.<br />’;
}
if

(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form

details below.\r
";

function clean_string($string) {
  $bad = array

(“content-type”,“bcc:”,“to:”,“cc:”,“href”);
return str_replace($bad,“”,$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\\r\

";
$email_message

.= "Last Name: “.clean_string($last_name).”\r
";
$email_message .= "Company:

“.clean_string($Company).”\r
";
$email_message .= "Add_1: ".clean_string

($Add_1)."\r
";
$email_message .= "Add_2: “.clean_string($Add_2).”\r
";

$email_message .= "City: “.clean_string($City).”\r
";
$email_message .= "State:

“.clean_string($State).”\r
";
$email_message .= "Zip: “.clean_string($Zip).”\r
";

$email_message .= "Country: “.clean_string($Country).”\r
";
$email_message .= "Email:

“.clean_string($email_from).”\r
";
$email_message .= "Telephone: ".clean_string

($telephone)."\r
";

$headers = 'From: '.$email_from."\r
“.
'Reply-To: '.$email_from.”\r
"

.
‘X-Mailer: PHP/’ . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header(“Location: $thankyou”);
?>
<script>location.replace(‘<?php echo $thankyou;?>’)</script>
<?php
}
die();
?>[/COLOR]

Here is the PHP settings I’m using as well free_settings.php):
[COLOR=“DarkOrchid”]<?php

$email_to = “contact@mentalnoteonline.com”; // your email address
$email_subject = “New Register”; // email subject line
$thankyou = “thankyou.htm”; // thank you page

?>[/COLOR]

Also here is the javascript I’m using (free_validation):

function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){return false;}
return true;}
function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;}
return true;}
function $$(id){if(!has_id(id)&&!has_name(id)){alert(“Field “+id+” does not exist!
Form validation configuration error.”);return false;}
if(has_id(id)){return document.getElementById(id).value;}else{return;}}
function $val(id){return document.getElementById(id);}
function trim(id){$val(id).value=$val(id).value.replace(/^\s+/,‘’).replace(/\s+$/,‘’);}
var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message=‘Please fix the following errors:

‘;var mess_part=’’;var to_focus=‘’;var tmp=true;for(var i=0;i<required.field.length;i++){if(this.checkit(required.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+required.field[i][2]+’ must be supplied
‘;if(has_id(required.field[i][0])&&to_focus.length===0){to_focus=required.field[i][0];}
tmp=false;}}
if(!tmp){alert(error_message);}
if(to_focus.length>0){document.getElementById(to_focus).focus();}
return tmp;},checkit:function(cvalue,ctype,cform){if(ctype==“NOT_EMPTY”){if(this.trim($$(cvalue)).length<1){return false;}else{return true;}}else if(ctype==“EMAIL”){exp=/[2]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length>0){return s.replace(/^\s+/,’‘).replace(/\s+$/,’');}else{return s;}}};

You can find the code source at this url [URL=“http://www.mentalnoteonline.com/register/register.html”]www.mentalnoteonline.com/register/register.html

It is also listed below:
[COLOR=“Indigo”]<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>Contact Us</title>
<script src=“free_validation.js”></script>
<script>
required.add(‘First_Name’,‘NOT_EMPTY’,‘Last Name’);
required.add(‘Last_Name’,‘NOT_EMPTY’,‘First Name’);
required.add(‘Email_Address’,‘EMAIL’,‘Email Address’);
required.add(‘Company’,‘NOT_EMPTY’,‘Your Message’);
required.add(‘Add_1’,‘NOT_EMPTY’,‘Address Line 1’);
required.add(‘City’,‘NOT_EMPTY’,‘City’);
required.add(‘State’,‘NOT_EMPTY’,‘State’);
required.add(‘Zip’,‘NOT_EMPTY’,‘Zip’);
required.add(‘Country’,‘NOT_EMPTY’,‘Country’);
</script>
<link rel=“stylesheet” type=“text/css” href=“free_styles.css”>

&lt;/head&gt;
&lt;body&gt;
&lt;div id="wrapper"&gt;

&lt;form name="contactformfree" method="post" action="free_process.php" onsubmit="return validate.check(this)"&gt;
&lt;table width="240px" class="cffree"&gt;
&lt;tr&gt;
 &lt;td colspan="2"&gt;
  &lt;p style="text-align:center"&gt;Fields marked with &lt;span class="required_star"&gt; * &lt;/span&gt; are required.&lt;/p&gt;

 &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="First_Name" class="required"&gt;First Name&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;
 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;

  &lt;input type="text" name="First_Name" id="First_Name" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
	&lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Last_Name" class="required"&gt;Last Name&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;
 &lt;/td&gt;

 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Last_Name" id="Last_Name" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Company" class="required"&gt;Company/Practice&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Company" id="Company" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Add_1" class="required"&gt;Address Line 1&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Add_1" id="Add_1" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Add_2" class="not-required"&gt;Line 2&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Add_2" id="Add_2" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="City" class="required"&gt;City&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="City" id="City" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="State" class="required"&gt;State&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="State" id="State" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Zip" class="required"&gt;Zip&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Zip" id="Zip" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Country" class="required"&gt;Country&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Country" id="Country" maxlength="80" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Email_Address" class="required"&gt;Email&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td align="right" valign="bottom" class="cffree_td"&gt;
  &lt;label for="Telephone_Number" class="not-required"&gt;Phone&lt;/label&gt;

 &lt;/td&gt;
 &lt;td valign="bottom" class="cffree_td"&gt;
  &lt;input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:140px"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td colspan="2" style="text-align:center"  class="cffree_td"&gt;
  &lt;input type="submit" value=" Submit Form "&gt;
 &lt;/td&gt;

&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/div&gt;

</body>
</html>[/COLOR]


  1. A-Za-z0-9._%- ↩︎

  2. a-zA-Z0-9._%- ↩︎

Dont suppose the Technical Information provided the verb in question - this seems to be a web server issue, rather than a code problem.

You might just happen to be correct because when posted on another server (which can be found at this address it seemed to actually do something but I still got an error message:
[COLOR=“Red”]
Sorry, but there were error(s) found with the form you submitted. These errors appear below.

We are sorry, but there appears to be a problem with the form you submitted.

Please go back and fix these errors.[/COLOR]

Yeah. That actually indiciates with certainty that this is a problem with your web server setup - gonna flag this for moving to their forum, and then when we get that fixed, if you’re still having issues, feel free to ask to have it moved back (or start a new thread)

PS: Give you a hint; why are you requiring the existance of Add2 and Telephone in your PHP, when you dont require it on your form?