ihatehippies 11 Junior Poster

I'm having a hard time getting my website to email the contents of form. It will send an email with the field labels but no values.. ie

name:
phone number:
email:
from: ()


the only thing I can get it to return is the ip

Here is the relevant html

<form id="FORMOB7DB261A1233A5C2" name="Form1" action="contact_us/formtoemail.php" enctype="text/plain" method="POST" onsubmit="return validateForm(this)"  onreset="return confirm('Do you really want to reset the form?')"  > 
            <input type="hidden" value="0" name="to"/> 
            <input type="hidden" value="A message from www.mysite.com" name="subject"/> 
            <input type="hidden" value="messenger@mysite.com" name="from"/>
            <input type="hidden" value=""<?php echo $ipi ?>"" name="ip"/>
            <input type="hidden" value=""<?php echo $httprefi ?>"" name="httpref"/>
            <input type="hidden" value=""<?php echo $httpagenti ?>"" name="httpagent"/>
 
            <div id="FORMTF7DB261A123031932" style=" position:absolute; top:370px; left:374px; width:419px; height:23px; z-index:28;"> 
              <div style="font-family: Arial; font-size: 10pt; font-weight: 500; font-style: normal; text-decoration: none; text-align: left;"> 
                <label for="name_field"><span style=" color: black; background: transparent;">Name</span></label> 
                <input type="TEXT" id="FORMTF7DB261A123031932R0" tabindex="1" name='name_field'  size=30  style="color: black; background: white;"onkeyup="if(value!='') validateLive(this); else clearError(this, 'errorI0')"onblur=" validateLive(this)" /> 
                <span style="visibility:hidden;font-size:10pt;font-family:Arial,Sans-Serif;" id="errorI0">please enter your name</span>              </div> 
            </div> 
 
            <div id="FORMTF7DB261A1231101062" style=" position:absolute; top:406px; left:322px; width:584px; height:23px; z-index:29;"> 
              <div style="font-family: Arial; font-size: 10pt; font-weight: 500; font-style: normal; text-decoration: none; text-align: left;"> 
                <label for="phone_field"><span style=" color: black; background: transparent;">Phone&#160;Number</span></label> 
                <input type="TEXT" id="FORMTF7DB261A1231101062R5" tabindex="2" name='phone_field'  size=30  style="color: black; background: white;"onkeyup="if(value!='') validateLive(this); else clearError(this, 'errorI1')"onblur=" validateLive(this)" /> 
                <span style="visibility:hidden;font-size:10pt;font-family:Arial,Sans-Serif;" id="errorI1">please enter a valid phone number</span>              </div> 
            </div> 
 
            <div id="FORMTF7DB261A1231273C21" style=" position:absolute; top:442px; left:373px; width:477px; height:23px; z-index:30;"> 
              <div style="font-family: Arial; font-size: 10pt; font-weight: 500; font-style: normal; text-decoration: none; text-align: left;"> 
                <label for="email_field"><span style=" color: black; background: transparent;">Email</span></label> 
                <input type="TEXT" id="FORMTF7DB261A1231273C21R4" tabindex="3" name='email_field'  size=30  style="color: black; background: white;"onkeyup="if(value!='') validateLive(this); else clearError(this, 'errorI2')"onblur=" validateLive(this)" /> 
                <span style="visibility:hidden;font-size:10pt;font-family:Arial,Sans-Serif;" id="errorI2">please enter a valid email address</span>              </div> 
            </div> 
 
            <div id="formta7DB261A12313A3D12" style=" position:absolute; top:475px; left:344px; width:548px; height:102px; z-index:31;"> 
              <div style="font-family: Arial; font-size: 10pt; font-weight: 500; font-style: normal; text-decoration: none; text-align: left;"> 
                <label for="message_field"><span style=" color: black; background: transparent;">Message</span></label> 
                <textarea id="formta7DB261A12313A3D12R0" name="message_field" rows="6" cols="30" tabindex="4" style="color: black; background: white;"onkeyup="if(value!='') validateLive(this); else clearError(this, 'errorT0')"onblur="if(value!='') validateLive(this); else clearError(this, 'errorT0')"></textarea> 
<span style="visibility:hidden;font-size:10pt;font-family:Arial,Sans-Serif;" id="errorT0">please enter a message to send</span>              </div> 
            </div> 
 
            <div id="FORMBS7DB261A12321E3732" style=" position:absolute; top:597px; left:407px; width:151px; height:22px; z-index:32;"> 
              <input type="submit" id="FORMBS7DB261A12321E3732" tabindex="5" name="Submit0" value= "Send Message" style="position:absolute; font-family: Arial; font-size: -13pt; font-weight: 500; font-style: normal; text-decoration: none; text-align: center; color: black; background: white; "  /> 
            </div> 
 
            <div id="FORMBR7DB261A1232332A52" style=" position:absolute; top:596px; left:548px; width:98px; height:22px; z-index:33;"> 
              <input type="reset" id="FORMBR7DB261A1232332A52" tabindex="6" name="Reset1" value= "Reset" style="position:absolute; font-family: Arial; font-size: -13pt; font-weight: 500; font-style: normal; text-decoration: none; text-align: center; color: black; background: white; "  /> 
            </div> 
          </form>

here is the javascript code that checks the fields

function validateForm(thisform){
	var isvalid=true;
	var nonvalid = 0;
	var x = 0;
	var array = thisform.getElementsByTagName("input");
	var array2 = new Array(0,0);
	var array3= thisform.getElementsByTagName("textarea");
	var array4= new Array(0);
	array2.length = array.length;
	array4.length = array3.length;
	var i = 0;
	for(x=0; x<array.length; x++){
		if(array[x].id){
			array2[i] = array[x];
			i++;
		}
	}
	array2.length = i;
	i=0;
	for(x=0; x<array3.length; x++){
		if(array3[x].id){
			array4[i] = array3[x];
			i++;
		}
	}
	array4.length = i;
	for(x=0; x<array2.length; x++){
		if(array2[x])
			if(!validateField(array2[x])){
				showError(array2[x],"errorI" + x);
				nonvalid++;
			}
			else clearError(array2[x],"errorI" + x);
		}
	for(x=0; x<array4.length; x++){
		if(array4[x]){
			if(!validateField(array4[x])){
				showError(array4[x],"errorT" + x);
				nonvalid++;
			}
			else clearError(array4[x],"errorT" + x);
		}
	}
		if(nonvalid > 0)
			isvalid = false;
    if(window.location.toString().substring(0,4) == "file"){
        //alert("Your website must be online to check this form's functions");
        return false;
    }
		return isvalid;
}

function validateLive(element){
	return true;
}

function showError(input,elementId){
	element = document.getElementById(elementId);
	if(element){
		element.style.visibility="visible";
		input.style.backgroundColor="#FFBBBB";
		input.style.border="1px solid red";
		input.focus();
	}
}

function clearError(input,elementId){
	element = document.getElementById(elementId);
	if(element){
		element.style.visibility="hidden";
		input.style.backgroundColor="";
		input.style.border="1px solid #444444";
	}
}

function validateField(element){
	if(element.id && element.id.length > 0){
		//R0 = generic required field
		elementid = element.id;
		elementid = elementid.toString();
		var length = elementid.length;
		var validatecode = element.id.toString().substr(length-2,2);
		switch(validatecode) {
		case "R0": return required(element);
		case "R1": return alphanumeric(element);
		case "R2": return alpha(element);
		case "R3": return numeric(element);
		case "R4": return email(element);
		case "R5": return phone(element);
		case "R6": return url(element);
		case "R7": return state(element);
		case "R8": return zip(element);
		case "R9": return hex(element);
		case "RA": return rgb(element);
		case "RB": return money(element);
		case "RC": return selection(element);
		case "N0": return notrequired(element);
		case "N1": return nralphanumeric(element);
		case "N2": return nralpha(element);
		case "N3": return nrnumeric(element);
		case "N4": return nremail(element);
		case "N5": return nrphone(element);
		case "N6": return nrurl(element);
		case "N7": return nrstate(element);
		case "N8": return nrzip(element);
		case "N9": return nrhex(element);
		case "NA": return nrrgb(element);
		case "NB": return nrmoney(element);
		default: return notrequired(element);
		}
	}
	else return true;
}

function notrequired(element){
	if(element.type == 'file') return true;
	regex = /(^[a-zA-Z\d\.\, \'\"\!\$\%\^\&\*\(\)\[\{\]\}\@\-#\+\=\_\:\;\\\/\?\r\n]*$)/;
	return regex.test(element.value);
}

function required(element){
	regex = /(^[a-zA-Z\d\.\, \'\"\!\$\%\^\&\*\(\)\[\{\]\}\@\-#\+\=\_\:\;\\\/\?\r\n]+$)/;
	return regex.test(element.value);
}

function numeric(element){
	regex = /^[\d\n]+$/;
	return regex.test(element.value);
}

function nrnumeric(element){
	regex = /^[\d\n]*$/;
	return regex.test(element.value);
}

function alpha(element){
	regex = /^[a-zA-Z \n]+$/;
	return regex.test(element.value);
}

function nralpha(element){
	regex = /^[a-zA-Z \n]*$/;
	return regex.test(element.value);
}

function alphanumeric(element){
	regex = /^[a-zA-Z\d \n]+$/;
	return regex.test(element.value);
}

function nralphanumeric(element){
	regex = /^[a-zA-Z\d \n]*$/;
	return regex.test(element.value);
}

function selection(element){
	return element.checked;
}

function email(element){
	regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-_]+\.[a-zA-Z]{2,4}$/;
	return regex.test(element.value);
}

function nremail(element){
	regex = /(^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-_]+\.[a-zA-Z]{2,4}$)|(^$)/;
	return regex.test(element.value);
}

function url(element){
	regex = /^((ftp)|(https?)):\/\/(\S+)(:[0-9]+)?(\/|\/([a-zA-Z#!:.?+=&%@!\-\/]))?$/;
	return regex.test(element.value);
}

function nrurl(element){
	regex = /(^((ftp)|(https?)):\/\/(\S+)(:[0-9]+)?(\/|\/([a-zA-Z#!:.?+=&%@!\-\/]))?$)|(^$)/;
	return regex.test(element.value);
}

function phone(element){
	regex = /(^(\d-)?\d{3}\-\d{3}\-\d{4}$)|(^\d{10}$)|(^[\d ]{7,14}$)/;
	return regex.test(element.value);
}

function nrphone(element){
	regex = /(^(\d-)?\d{3}\-\d{3}\-\d{4}$)|(^\d{10}$)|(^[\d ]{7,14}$)|(^$)/;
	return regex.test(element.value);
}

function state(element){
	return alpha(element);
}

function nrstate(element){
	return nralpha(element);
}

function zip(element){
	regex = /^[a-zA-Z\d\- ]{1,16}$/;
	return regex.test(element.value);
}

function nrzip(element){
	regex = /(^[a-zA-Z\d\- ]{1,16}$)|(^$)/;
	return regex.test(element.value);
}

function hex(element){
	regex = /^((0x)|(\$))[a-fA-F\d]+$/;
	return regex.test(element.value);
}

function nrhex(element){
	regex = /(^((0x)|(\$))[a-fA-F\d]+$)|(^$)/;
	return regex.test(element.value);
}

function rgb(element){
	regex = /(^\#[a-fA-F\d]{3}$)|(^\#[a-fA-F\d]{6}$)/;
	return regex.test(element.value);
}

function nrrgb(element){
	regex = /(^\#[a-fA-F\d]{3}$)|(^\#[a-fA-F\d]{6}$)|(^$)/;
	return regex.test(element.value);
}

function money(element){
	regex = /(^\$[\d,]+.[\d]{0,2}$)|(^[\d.]+,[\d]{0,2}$)|(^[\d.]+,[\d]{0,2}$)|(^[\d,.]+[,.]+[\d]{0,2}$)/;
	return regex.test(element.value);
}

function nrmoney(element){
	regex = /(^\$[\d,]+.[\d]{0,2}$)|(^[\d.]+,[\d]{0,2}$)|(^[\d.]+,[\d]{0,2}$)|(^[\d,.]+[,.]+[\d]{0,2}$)|(^$)/;
	return regex.test(element.value);
}

and here is the php script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) --> 
<!-- Reminder: Change 'YourEmail' to Your real email --> 

<?php

$name = $_POST['name_field']; 
$email = $_POST['email_field']; 
$message= $_POST['message_field'];
$number = $_POST['number_field'];
$ip = $_SERVER['REMOTE_ADDR'];
 $hostaddress = gethostbyaddr($ip);


$todayis = date("l, F j, Y, g:i a") ;
 
$subject = 'A message from mysite.com'; 


$email_message = " $todayis [EST] \n
Phone Number: $number \n
Message: $message \n 
From: $name ($email)\n
Additional Info : IP = $ip \n
";

$from = "messenger@mysite.com\r\n";


mail("info@mysite.com", $subject, $email_message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank you for the message <?php echo $name ?> ( <?php echo $email ?> ) 
<br />

Phone Number: <?php echo $number ?>
<br /> 


<br /><br />
<a href="http://mysite.com"> Return to Home Page </a> 
</p> 

</body>
</html>

I'm new to php and javascript so I might be missing something obvious, thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.