Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-12-2012, 09:53 PM   PM User | #1
notoriouseddie
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
notoriouseddie is an unknown quantity at this point
Can someone please resolve my form issues?!

Hi all,

New to the forum. I have downloaded a template off template monster and am currently in the process of modifying it to suit my needs.

I am currently working on the contact page which has a form and appears to be working fine however I have yet to receive an e-mail once the form is submitted. The forms uses Javascript (forms.js) and a MailHandler.php file.

I cant understand what is going wrong as everything seems to be working but perhaps im missing the obvious - You can view the page on http://zoeandeddie.webspace.virginme...m/index-4.html

Below is the content of the two files - ive replaced my actual email address with 'myemail@address.com:

forms.js

Code:
;(function($){
	$.fn.forms=function(o){
		return this.each(function(){
			var th=$(this)
				,_=th.data('forms')||{
					errorCl:'error',
					emptyCl:'empty',
					invalidCl:'invalid',
					notRequiredCl:'notRequired',
					successCl:'success',
					successShow:'4000',
					mailHandlerURL:'bin/MailHandler.php',
					ownerEmail:'myemail@address.com',
					stripHTML:true,
					smtpMailServer:'localhost',
					targets:'input,textarea',
					controls:'a[data-type=reset],a[data-type=submit]',
					validate:true,
					rx:{
						".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
						".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
						".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
						".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
						".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
						".message":{rx:/.{20}/,target:'textarea'}
					},
					preFu:function(){
						_.labels.each(function(){
							var label=$(this),
								inp=$(_.targets,this),
								defVal=inp.val(),
								trueVal=(function(){
											var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html()
											return defVal==''?defVal:tmp
										})()
							trueVal!=defVal
								&&inp.val(defVal=trueVal||defVal)
							label.data({defVal:defVal})								
							inp
								.bind('focus',function(){
									inp.val()==defVal
										&&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl))
								})
								.bind('blur',function(){
									_.validateFu(label)
									if(_.isEmpty(label))
										inp.val(defVal)
										,_.hideErrorFu(label.removeClass(_.invalidCl))											
								})
								.bind('keyup',function(){
									label.hasClass(_.invalidCl)
										&&_.validateFu(label)
								})
							label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
						})
						_.success=$('.'+_.successCl,_.form).hide()
					},
					isRequired:function(el){							
						return !el.hasClass(_.notRequiredCl)
					},
					isValid:function(el){							
						var ret=true
						$.each(_.rx,function(k,d){
							if(el.is(k))
								ret=d.rx.test(el.find(d.target).val())										
						})
						return ret							
					},
					isEmpty:function(el){
						var tmp
						return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal')
					},
					validateFu:function(el){							
						el.each(function(){
							var th=$(this)
								,req=_.isRequired(th)
								,empty=_.isEmpty(th)
								,valid=_.isValid(th)								
							
							if(empty&&req)
								_.showEmptyFu(th.addClass(_.invalidCl))
							else
								_.hideEmptyFu(th.removeClass(_.invalidCl))
							
							if(!empty)
								if(valid)
									_.hideErrorFu(th.removeClass(_.invalidCl))
								else
									_.showErrorFu(th.addClass(_.invalidCl))								
						})
					},
					getValFromLabel:function(label){
						var val=$('input,textarea',label).val()
							,defVal=label.data('defVal')								
						return label.length?val==defVal?'nope':val:'nope'
					}
					,submitFu:function(){
						_.validateFu(_.labels)							
						if(!_.form.has('.'+_.invalidCl).length)
							$.ajax({
								type: "POST",
								url:_.mailHandlerURL,
								data:{
									name:_.getValFromLabel($('.name',_.form)),
									email:_.getValFromLabel($('.email',_.form)),
									phone:_.getValFromLabel($('.phone',_.form)),
									fax:_.getValFromLabel($('.fax',_.form)),
									state:_.getValFromLabel($('.state',_.form)),
									message:_.getValFromLabel($('.message',_.form)),
									owner_email:_.ownerEmail,
									stripHTML:_.stripHTML
								},
								success: function(){
									_.showFu()
								}
							})			
					},
					showFu:function(){
						_.success.slideDown(function(){
							setTimeout(function(){
								_.success.slideUp()
								_.form.trigger('reset')
							},_.successShow)
						})
					},
					controlsFu:function(){
						$(_.controls,_.form).each(function(){
							var th=$(this)
							th
								.bind('click',function(){
									_.form.trigger(th.data('type'))
									return false
								})
						})
					},
					showErrorFu:function(label){
						label.find('.'+_.errorCl).slideDown()
					},
					hideErrorFu:function(label){
						label.find('.'+_.errorCl).slideUp()
					},
					showEmptyFu:function(label){
						label.find('.'+_.emptyCl).slideDown()
						_.hideErrorFu(label)
					},
					hideEmptyFu:function(label){
						label.find('.'+_.emptyCl).slideUp()
					},
					init:function(){
						_.form=_.me						
						_.labels=$('label',_.form)

						_.preFu()
						
						_.controlsFu()
														
						_.form
							.bind('submit',function(){
								if(_.validate)
									_.submitFu()
								else
									_.form[0].submit()
								return false
							})
							.bind('reset',function(){
								_.labels.removeClass(_.invalidCl)									
								_.labels.each(function(){
									var th=$(this)
									_.hideErrorFu(th)
									_.hideEmptyFu(th)
								})
							})
						_.form.trigger('reset')
					}
				}
			_.me||_.init(_.me=th.data({forms:_}))
			typeof o=='object'
				&&$.extend(_,o)
		})
	}
})(jQuery)
$(function(){
	$('#contact-form').forms({
		ownerEmail:'myemail@address.com'
	})
})
MailHandler.php

Code:
<?php
	$owner_email = $_POST["owner_email"];
	$headers = 'From:' . $_POST["email"];
	$subject = 'A message from your site visitor ' . $_POST["name"];
	$messageBody = "";
	
	if($_POST['name']!='nope'){
		$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
		$messageBody .= '<br>' . "\n";
	}
	if($_POST['email']!='nope'){
		$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
		$messageBody .= '<br>' . "\n";
	}else{
		$headers = '';
	}
	if($_POST['state']!='nope'){		
		$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
		$messageBody .= '<br>' . "\n";
	}
	if($_POST['phone']!='nope'){		
		$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
		$messageBody .= '<br>' . "\n";
	}	
	if($_POST['fax']!='nope'){		
		$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
		$messageBody .= '<br>' . "\n";
	}
	if($_POST['message']!='nope'){
		$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
	}
	
	if($_POST["stripHTML"] == 'true'){
		$messageBody = strip_tags($messageBody);
	}
	
	try{
		if(!mail($owner_email, $subject, $messageBody, $headers)){
			throw new Exception('mail failed');
		}else{
			echo 'mail sent';
		}
	}catch(Exception $e){
		echo $e->getMessage() ."\n";
	}
?>

Last edited by notoriouseddie; 03-12-2012 at 10:01 PM.. Reason: typo
notoriouseddie is offline   Reply With Quote
Old 03-12-2012, 11:02 PM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
your mail handler php is returning this:


Code:
<br />
<b>Parse error</b>:  parse error, unexpected '{' in <b>/tier-11/pwpstore3/43/zoeandeddie/htdocs/mailhandler.php</b> on line <b>37</b><br />
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 03-12-2012, 11:19 PM   PM User | #3
notoriouseddie
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
notoriouseddie is an unknown quantity at this point
thank you for the reply. What should I do to resolve this?
notoriouseddie is offline   Reply With Quote
Old 03-12-2012, 11:54 PM   PM User | #4
notoriouseddie
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
notoriouseddie is an unknown quantity at this point
I'm wondering if this is something to do with the server I am using just now to test the website in that it may not support PHP5?

Could this be the probllem? And if so, what modifications can I make to the code to make it PHP4 compatible?

Thanks in advance.
notoriouseddie is offline   Reply With Quote
Old 03-14-2012, 04:14 AM   PM User | #5
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
are you absolutely certain that is the code you have in the php file?

also I tried : http://zoeandeddie.webspace.virginme...ailhandler.php

and the file doesnt appear to be there....
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 06-16-2012, 07:08 PM   PM User | #6
afagard
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
afagard is an unknown quantity at this point
Ok first 'bin/MailHandler.php' in the forms.js replace with ur contact form url
for me it was contactengine.php

$(function(){
$('#contact-form').forms({
ownerEmail:'myemail@address.com'
})
})
Not sure u need this, with my template I commented it out because it was causing multiple form submissions (like 5!) haha.

On ur contact page be sure to include the action
<form action="contactengine.php" id="ContactForm">

Now for the php contact form I used the simplest one I could find as complex ones arnt needed for this type of form:

PHP Code:
<?php
/* Simple form submission */

$emailFrom "fagarddesigns@gmail.com";
$emailTo "alexander_fagard@mac.com";
$Subject "FAGARDDESIGNS - Website contact form submission";
$name Trim(stripslashes($_POST['name'])); 
$phone Trim(stripslashes($_POST['phone'])); 
$email Trim(stripslashes($_POST['email'])); 
$message Trim(stripslashes($_POST['message'])); 

// prepare email body text
$Body "Form submission from contact page. Please answer within 2 business days as per policy.";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";

// send email 
$success mail($emailTo$Subject$Body"From: <$emailFrom>");
?>
afagard is offline   Reply With Quote
Old 07-12-2012, 09:01 PM   PM User | #7
zimylink
New to the CF scene

 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
zimylink is an unknown quantity at this point
I just solved the problem with the email functionality. I hope you'll still find it relevant by the time you get this;

Open the MailHandler.php script and look for the line with this part

". $_POST["name"];"

Try closing up the space between the full stop (.) and the dollar sign ($)

e.g. ".$_POST["name"];"

Do this for all other lines containing this.

This should fix the bug. Please let me know if it works for you.
Cheers!
zimylink is offline   Reply With Quote
Old 08-24-2012, 05:27 PM   PM User | #8
blackcell989
New to the CF scene

 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
blackcell989 is an unknown quantity at this point
Hi notoriouseddie. Did you ever resolve your problem?
blackcell989 is offline   Reply With Quote
Old 09-16-2012, 07:44 PM   PM User | #9
jmorduna
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jmorduna is an unknown quantity at this point
hello.

I have the same problem with the same code (template...)

On the instructions they put you have to change owneremail and thats it. But it doesn't works, and I really dont know if there is fault of the server, or I'm missing some ';'....

I didnt want to open a new thread so I hope we can have a solution (I already tried the ones you commented some months ago)

the mailhandler respose is mail sent, and the contact-form shows the sent message, but there is no email even at the spam folder, i dunno what to do. Thanks in advance

solution: server problem.

Last edited by jmorduna; 09-17-2012 at 03:15 AM..
jmorduna is offline   Reply With Quote
Old 10-31-2012, 10:50 PM   PM User | #10
bhamilto66
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bhamilto66 is an unknown quantity at this point
It took me forever to figure this one out...

Change your MailHandler.php code to look like the below or just cut and paste this code. Note: make sure you are entering a valid email address on the HTML contact form or it will not work, I tested with my yahoo account email address.

PHP Code:
<?php
    $owner_email 
"YourEmailAddressHere@xxx.com";
    
$headers 'From:' $_POST["email"];
    
$subject 'A message from your site visitor ' $_POST["name"];
    
$messageBody "";
    
    if(
$_POST['name']!='nope'){
        
$messageBody .= '<p>Visitor: ' $_POST["name"] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }
    if(
$_POST['email']!='nope'){
        
$messageBody .= '<p>Email Address: ' $_POST['email'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }else{
        
$headers '';
    }
    if(
$_POST['state']!='nope'){        
        
$messageBody .= '<p>State: ' $_POST['state'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }
    if(
$_POST['phone']!='nope'){        
        
$messageBody .= '<p>Phone Number: ' $_POST['phone'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }    
    if(
$_POST['fax']!='nope'){        
        
$messageBody .= '<p>Fax Number: ' $_POST['fax'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }
    if(
$_POST['message']!='nope'){
        
$messageBody .= '<p>Message: ' $_POST['message'] . '</p>' "\n";
    }
    
    if(
$_POST["stripHTML"] == 'true'){
        
$messageBody strip_tags($messageBody);
    }
    
        
mail($owner_email$subject$messageBody$headers)

?>

Last edited by VIPStephan; 11-01-2012 at 08:29 AM.. Reason: added code BB tags
bhamilto66 is offline   Reply With Quote
Old 11-08-2012, 07:10 AM   PM User | #11
kateisgreat
New to the CF scene

 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kateisgreat is an unknown quantity at this point
I'm having the same problems here. I am wondering if I need to change the SMTPmailserver to something other than "localhost". Client's website is hosted at Bluehost, but all mail is setup through gmail exchanges. Is it possible to set it up to keep this scheme (mail at domain is forwarded to google exchange) but still have the form send email?
kateisgreat is offline   Reply With Quote
Old 02-28-2013, 05:17 PM   PM User | #12
facha_2000
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
facha_2000 is an unknown quantity at this point
Exclamation I solve the issue.

Code:
//forms
;(function($){
	$.fn.forms=function(o){
		return this.each(function(){
			var th=$(this)
				,_=th.data('forms')||{
					errorCl:'error',
					emptyCl:'empty',
					invalidCl:'invalid',
					notRequiredCl:'notRequired',
					successCl:'success',
					successShow:'4000',
					mailHandlerURL:'PATCH_TO_Mailhandler.php',
					ownerEmail:'youremail@email.com',
					stripHTML:true,
					smtpMailServer:'yoursmtpserver.com',
					targets:'input,textarea',
					controls:'a[data-type=reset],a[data-type=submit]',
					validate:true,
					rx:{
						".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
						".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
						".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
						".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
						".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
						".message":{rx:/.{20}/,target:'textarea'}
					},
					preFu:function(){
						_.labels.each(function(){
							var label=$(this),
								inp=$(_.targets,this),
								defVal=inp.val(),
								trueVal=(function(){
											var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html()
											return defVal==''?defVal:tmp
										})()
							trueVal!=defVal
								&&inp.val(defVal=trueVal||defVal)
							label.data({defVal:defVal})								
							inp
								.bind('focus',function(){
									inp.val()==defVal
										&&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl))
								})
								.bind('blur',function(){
									_.validateFu(label)
									if(_.isEmpty(label))
										inp.val(defVal)
										,_.hideErrorFu(label.removeClass(_.invalidCl))											
								})
								.bind('keyup',function(){
									label.hasClass(_.invalidCl)
										&&_.validateFu(label)
								})
							label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
						})
						_.success=$('.'+_.successCl,_.form).hide()
					},
					isRequired:function(el){							
						return !el.hasClass(_.notRequiredCl)
					},
					isValid:function(el){							
						var ret=true
						$.each(_.rx,function(k,d){
							if(el.is(k))
								ret=d.rx.test(el.find(d.target).val())										
						})
						return ret							
					},
					isEmpty:function(el){
						var tmp
						return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal')
					},
					validateFu:function(el){							
						el.each(function(){
							var th=$(this)
								,req=_.isRequired(th)
								,empty=_.isEmpty(th)
								,valid=_.isValid(th)								
							
							if(empty&&req)
								_.showEmptyFu(th.addClass(_.invalidCl))
							else
								_.hideEmptyFu(th.removeClass(_.invalidCl))
							
							if(!empty)
								if(valid)
									_.hideErrorFu(th.removeClass(_.invalidCl))
								else
									_.showErrorFu(th.addClass(_.invalidCl))								
						})
					},
					getValFromLabel:function(label){
						var val=$('input,textarea',label).val()
							,defVal=label.data('defVal')								
						return label.length?val==defVal?'nope':val:'nope'
					}
					,submitFu:function(){
						_.validateFu(_.labels)							
						if(!_.form.has('.'+_.invalidCl).length)
							$.ajax({
								type: "POST",
								url:_.mailHandlerURL,
								data:{
									name:_.getValFromLabel($('.name',_.form)),
									email:_.getValFromLabel($('.email',_.form)),
									phone:_.getValFromLabel($('.phone',_.form)),
									fax:_.getValFromLabel($('.fax',_.form)),
									state:_.getValFromLabel($('.state',_.form)),
									message:_.getValFromLabel($('.message',_.form)),
									owner_email:_.ownerEmail,
									stripHTML:_.stripHTML
								},
								success: function(){
									_.showFu()
								}
							})			
					},
					showFu:function(){
						_.success.slideDown(function(){
							setTimeout(function(){
								_.success.slideUp()
								_.form.trigger('reset')
							},_.successShow)
						})
					},
					controlsFu:function(){
						$(_.controls,_.form).each(function(){
							var th=$(this)
							th
								.bind('click',function(){
									_.form.trigger(th.data('type'))
									return false
								})
						})
					},
					showErrorFu:function(label){
						label.find('.'+_.errorCl).slideDown()
					},
					hideErrorFu:function(label){
						label.find('.'+_.errorCl).slideUp()
					},
					showEmptyFu:function(label){
						label.find('.'+_.emptyCl).slideDown()
						_.hideErrorFu(label)
					},
					hideEmptyFu:function(label){
						label.find('.'+_.emptyCl).slideUp()
					},
					init:function(){
						_.form=_.me						
						_.labels=$('label',_.form)

						_.preFu()
						
						_.controlsFu()
														
						_.form
							.bind('submit',function(){
								if(_.validate)
									_.submitFu()
								else
									_.form[0].submit()
								return false
							})
							.bind('reset',function(){
								_.labels.removeClass(_.invalidCl)									
								_.labels.each(function(){
									var th=$(this)
									_.hideErrorFu(th)
									_.hideEmptyFu(th)
								})
							})
						_.form.trigger('reset')
					}
				}
			_.me||_.init(_.me=th.data({forms:_}))
			typeof o=='object'
				&&$.extend(_,o)
		})
	}
})(jQuery)
$(window).load(function(){
	$('#contact-form').forms({
		ownerEmail:'youremail@yourdomainnameoftheemail.com'
	})
})
PHP Code:
<?php
    $owner_email 
$_POST["owner_email"];
    
$headers 'From:' $_POST["email"];
    
$subject 'A message from your site visitor ' $_POST["name"];
    
$messageBody "";
    
    if(
$_POST['name']!='nope'){
        
$messageBody .= '<p>Visitor: ' $_POST["name"] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }
    if(
$_POST['email']!='nope'){
        
$messageBody .= '<p>Email Address: ' $_POST['email'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }else{
        
$headers '';
    }
    if(
$_POST['state']!='nope'){        
        
$messageBody .= '<p>State: ' $_POST['state'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }
    if(
$_POST['phone']!='nope'){        
        
$messageBody .= '<p>Phone Number: ' $_POST['phone'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }    
    if(
$_POST['fax']!='nope'){        
        
$messageBody .= '<p>Fax Number: ' $_POST['fax'] . '</p>' "\n";
        
$messageBody .= '<br>' "\n";
    }
    if(
$_POST['message']!='nope'){
        
$messageBody .= '<p>Message: ' $_POST['message'] . '</p>' "\n";
    }
    
    if(
$_POST["stripHTML"] == 'true'){
        
$messageBody strip_tags($messageBody);
    }
    
    try{
        if(!
mail($owner_email$subject$messageBody$headers)){
            throw new 
Exception('mail failed');
        }else{
            echo 
'mail sent';
        }
    }catch(
Exception $e){
        echo 
$e->getMessage() ."\n";
    }
?>
Code:
											<form id="contact-form" action="_PATCH_TO_Mailhandler.php" method="post" enctype="multipart/form-data">
												<fieldset>
													<label class="name">
														<input type="text" value="Name">
															<span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span>
													</label>
													<label class="email">
														<input type="text" value="E-mail">
															<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span>
													</label>
													<label class="phone">
														<input type="text" value="Telephone">
															<span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span>
													</label>
													<label class="message">
														<textarea>Message</textarea>
															<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
													</label>
													<div class="success">Contact form submitted!<br>
															<strong>We will be in touch soon.</strong>
													</div>
													<div class="buttons2">
															<a href="#" data-type="reset" class="button2">Reset</a>
															<a href="#" data-type="submit" class="button2">Submit</a>
													</div>
												</fieldset>
												</form>
welll, this is it, you can change with css the form, colors, and other stuff, but this is that make the form function. :B
EDIT: everything in black, you can change it. BLACK *<B>*

Last edited by facha_2000; 02-28-2013 at 05:19 PM.. Reason: i forgot something
facha_2000 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:30 AM.


Advertisement
Log in to turn off these ads.