logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 08-23-2011, 03:21 PM   #1
dahliacreative
 
Join Date: Feb 2011
Posts: 7
Default Html Email Form

Hi I'm trying to create a form to email script that sends the form information in an html format.

Can anyone see why my code wouldn't be working??

Code:
<?php
	
	//Check if the form has sent data
	if(isset($_POST['submit'])) {
		
		//Create variables
		$to = "simon@creative-jar.com";
		$subject = "Website Enquiry";
		$name = $_POST['name'];
		$email = $_POST['email'];
		$telephone = $_POST['telephone'];
		$message = $_POST['message'];
		
		//Create the body
		$body = '<html><body>';
		$body .= '<h1>Hello, World!</h1>';
		$body .= '</body></html>';
		
		//Create headers
		$headers = "From: $name\r\n";
		$headers .= "Reply-to: $email\r\n";
		$headers .= "MIME-Version: 1.0\r\n";
		$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
		
		//Send the email
		if(mail($to, $subject, $body, $headers)) {
			
			//Display Success Message
			echo '<p class="success">Thank you, your message has been sent successfully. Some one will be in touch within 48hours.</p>';
			
		} else {
			
			//Display Success Message
			echo '<p class="error">There has been a problem delivering your message, please try again.</p>';
			
		};
		
	};
?>

<form method="post" action="mail.php">
	<input type="text" name="name" />
	<input type="text" name="email" />
	<input type="text" name="telephone" />
	<textarea name="message"></textarea>
	<input type="submit" value="submit" name="submit" />
</form>
dahliacreative is offline   Reply With Quote
Old 08-24-2011, 03:06 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

Code:
$body = '<html><body>';
		$body .= '<h1>Hello, World!</h1>';
		$body .= '</body></html>';
you have to include form posts in the body
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 08-24-2011, 03:23 PM   #3
dahliacreative
 
Join Date: Feb 2011
Posts: 7
Default

I've got the form emailing,
But the headers are coming all weird. Can anyone see where I'm going wrong???

PHP Code:
<?php
    
//Check if the form has sent data
    
if(isset($_POST['submit'])) {
        
//Create variables
        
$to "dahliamurder@hotmail.com";
        
$subject "Website Enquiry";
        
$name $_POST['name'];
        
$email $_POST['email'];
        
$telephone $_POST['telephone'];
        
$message $_POST['message'];

        
//Create the body
        
$body '<html><body><table width="100%" bgcolor="#BBD3CD">';
        
$body .= '<tr><td align="center"><table width="600" bgcolor="#FDFAF4"><tr><td align="left">';
        
$body .= '<img src="logo.jpg" alt="Decadent Cakes"/>';
        
$body .= '<p><strong>Client Name:</strong> '.$name.'</p>';
        
$body .= '<p><strong>Client Email:</strong> '.$email.'</p>';
        
$body .= '<p><strong>Client Telephone:</strong> '.$telephone.'</p>';
        
$body .= '<p><strong>Client Message:</strong></p>';
        
$body .= '<p>'.$message.'</p>';
        
$body .= '</td></tr></table></td></tr>';
        
$body .= '</body></html></table>';
        
        
//Create headers
        
$headers "From: $name\r\n";
        
$headers .= "Reply-to: $email\r\n";
        
$headers .= "MIME-Version: 1.0\r\n";
        
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        
        
//Send the email
        
if(mail($to$subject$body$headers)) {
            
//Display Success Message
            
echo '<p id="success">Thank you, your message has been sent successfully. Some one will be in touch within 48hours. <a href="#">Close</a></p>';
        } else {
            
//Display Success Message
            
echo '<p id="error">There has been a problem delivering your message, please try again. <a href="#">Close</a></p>';
        };
    };
?>
dahliacreative is offline   Reply With Quote
Old 08-25-2011, 12:50 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

$headers="Content-Type: text/html; charset=windows-1252 \n";
$headers.="From: $name \n";
$headers .= "Reply-to: $email \n"
$headers.="X-mailer:";
try this
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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. The time now is 07:25 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com