Not logged in? Join one of the bigest Law Forums on the Internet! Join Now!   Latest blog post: Research Law Professors Before Choosing Law Schools

Advertisments:




Sponsor Links:

Discount Legal Forms
Discounted Legal Texts


PHP/HTML Email for script isn't working?

Dealing with a class action? Discuss it here

PHP/HTML Email for script isn't working?

Postby bearchan » Fri Feb 24, 2012 12:42 am

I've been working on a website and have been messing around with the design of the feedback form and somehow I broke it. :P
The problem is this: it's goes through the Script correctly, but doesn't actually send it. And I can't fix it.
Below is the script for all the elements involved..

HTML Form:

<fieldset style="border-color:#7b7b7b;">
<legend><span class="basicBluefontLarge">Feedback Form</span></legend>

<form name="freecontactform" method="post" action="assets/scripts/freecontactformpr… onSubmit="return validate.check(this)">
<span class="basicGrayfontSmall">Fields marked with <span class="required_star">*</span> are required!</span>

<input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:230px">
<label for="Full_Name" class="basicGrayfontSmall">Full Name or Steam Name<span class="required_star"> * </span></label>

<input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:230px">
<label for="Email_Address" class="basicGrayfontSmall">Email Address<span class="required_star"> * </span></label>

<textarea style="width:750px;height:160px" name="comments" id="comments" maxlength="2000"></textarea>
<label for="comments" class="basicGrayfontSmall">Your Message</label>

<center>
<div class="antispammessage">
<span class="basicGrayfontSmall">To help prevent automated spam, please answer this question</span>

<div class="basicGrayfontSmall">
<span class="required_star"> * </span>
Using only numbers, what is 10 plus 15?  
<input type="text" name="AntiSpam" id="AntiSpam" maxlength="100" style="width:30px">
</div>
</div>
</center>

<center>
<input type="submit" value=" Send! "> <input type="reset" value=" Reset "></center>
</form>

</fieldset>


PHP Script:

<?php
if(isset($_POST['Email_Address'])) {

include 'freecontactformsettings.php';

function died($error) {
echo "Sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.";
echo $error."";
echo "Please go back and fix these errors.";
die();
}

if(!isset($_POST['Full_Name']) ||
!isset($_POST['Email_Address']) ||
!isset($_POST['comments']) ||
!isset($_POST['AntiSpam'])
) {
died('Sorry, there appears to be a problem with your form submission.');
}

$full_name = $_POST['Full_Name']; // required
$email_from = $_POST['Email_Address']; // required
$comments = $_POST['comments']; // required
$antispam = $_POST['AntiSpam']; // required

$error_message = "";

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Z…
if(preg_match($email_exp,$email_from)==0… {
$error_message .= 'The Email Address you entered does not appear to be valid.';
}
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.';
}

if($antispam <> $antispam_answer) {
$error_message .= 'The Anti-Spam answer you entered is not correct.';
}

if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\r\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:")…
return str_replace($bad,"",$string);
}

$email_message .= "Full Name: ".clean_string($full_name)."\r\n";
$email_message .= "Email: ".clean_string($email_from)."\r\n";
$email_message .= "Message: ".clean_string($comments)."\r\n";

$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@
bearchan
 
Posts: 21
Joined: Fri Apr 01, 2011 6:31 pm
Top

Return to Class Action

 


  • Related topics
    Replies
    Views
    Last post