Jump to content

PHP Form sends blank emails


rsrwebs

Recommended Posts

Hi,

 

I have a mailing sign-up form that works when I try to use it, but I keep getting emails that list the fields (name, email, etc) but no info after them. I just found however, that one can click "send" without filling out the fields. I have a javascript that is supposed to stop it, but its not working.

 

Here's the whole form page's code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
}
Body {background:#000;
overflow-y:hidden;
}

</style>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body text="#FFFFFF" link="#CCCCCC" vlink="#999999" alink="#FFFFFF">
<script language="JavaScript">

function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("Name", "City", 

"State", "Email");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Name", "City", 

"State", "Email");
// dialog message
var alertMsg = "Please complete the following fields:\n";

var l_Msg = alertMsg.length;

for (var i = 0; i < fieldRequired.length; i++){
	var obj = formobj.elements[fieldRequired[i]];
	if (obj){
		switch(obj.type){
		case "select-one":
			if (obj.selectedIndex == -1 || 

obj.options[obj.selectedIndex].text == ""){
				alertMsg += " - " + 

fieldDescription[i] + "\n";
			}
			break;
                       case "text":
		case "textarea":
			if (obj.value == "" || obj.value == 

null){
				alertMsg += " - " + 

fieldDescription[i] + "\n";
			}
			break;
		case "text":
		case "textarea":
			if (obj.value == "" || obj.value == 

null){
				alertMsg += " - " + 

fieldDescription[i] + "\n";
			}
			break;
		case "text":
		case "textarea":
			if (obj.value == "" || obj.value == 

null){
				alertMsg += " - " +
fieldDescription[i] + "\n";
			}
			break;
		case "text":
		case "textarea":
			if (obj.value == "" || obj.value == 

null){
				alertMsg += " - " + 

fieldDescription[i] + "\n";
			}
		}
	}
}

if (alertMsg.length == l_Msg){
	return true;
}else{
	alert(alertMsg);
	return false;
}
}
// -->
</script>

<script type="text/javascript">

/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var 

emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}

</script>
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");

?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<form method="POST" action="sendemail.PHP" name="mailinglist" id="mailinglist">
 <div align="left"> 
   <p align="center">
     Name (First & Last):<br>
     <input type="text" name="Name"/>
     <br>
     <br>
     City:<br>
     <input type="text" name="City" />
     <br>
     <br>
     State:<br>
     <input type="text" name="State"/>
     <br>
     <br>
     Email:<br>
     <input type="text" name="Email"/>
     <br>
     <br>
<input type="submit" VALUE="Sign Me Up" onClick="alert('Thank you! Your form has been sent.')" />
   </p>
   </div>
</form> 
</form>
</body>
</html>

 

Any help would be greatly appreciated. :)

 

-Raven

Link to comment
Share on other sites

  • 2 weeks later...

I'm not seeing any call to the javascript function formCheck(formobj) which would check your form. I'd probably suggest going back to Dynamic Drive and checking the instructions for that particular script -- I'm sure they include some sort of instructions on how to call validation when a user submits the form.

 

Yep, that was it, lol. Thank you, again. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...