Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dreamweaver Forms with PHP posting to MySQL table, emailing response

Posted on 2007-11-29
3
Medium Priority
?
781 Views
Last Modified: 2013-12-12
I have 3 questions.  I have designed and tested a php form in Dreamweaver CS3.  This form will post to MySQL database perfectly.

However, i want to script an email back to the user acknowledging the information entered in the form being submited.  I also want to be able to email myself the form information.

What is the best way to acheive this?
0
Comment
Question by:andrewl77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
simonkin earned 500 total points
ID: 20372558
Hi, Try this....
<?php
 
	// Set the carriage return (End of Line)
	$eol="\r\n";
	
	// Set the email from name
	$fromName = "Your Name";
	
	// Set the from email
	$fromEmail = "you@yourdomain.com";
	
	// Set your domain
	$domain = "domain.com"
	
	// Set the message subject
	$subject = "Your email subject";
	
	// Set the admin email
	$emailAdmin = "you@yourdomain.com";
	
	// Set the user email - you'll have to get this from the form post
	$userEmail = "user@domain.com";
	
	// Set the email body (Just an example, set your own body to suit where variables are the variables from your form)
	$body = "Your email introduction..." . $eol . $eol;
	$body .= "Variable 1 = $variable1" .$eol;
	$body .= "Variable 2 = $variable2" .$eol;
	$body .= "Variable 3 = $variable3" .$eol;
	$body .= "Variable 4 = $variable4" .$eol;
	$body .= "Variable 5 = $variable5" .$eol;
	
	// Set the mime boundary
	$mime_boundary = md5(time());
	
	// Set the headers
	$headers = "From: $fromName <$fromEmail>" . $eol;
	$headers .= "Reply-To: $fromName <$fromEmail>" . $eol;
	$headers .= "Return-Path: $fromName <$fromEmail>" . $eol;
	$headers .= "Message-ID: <" . time() . "-$domain>" . $eol;
	$headers = "X-Mailer: PHP v" . phpversion() . $eol;
	
	// Send the email as HTML
	$headers .= "Content-Type: multipart/mixed; boundary=\"" . $mime_boundary . "\"" . $eol . $eol;
	
	// Open the first part of the mail
	$msg = "--" . $mime_boundary . $eol;
	
	// Define a different MIME boundary for this section
	$htmlalt_mime_boundary = $mime_boundary."_htmlalt"; 
	
	// Setup for text OR html -
	$msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;
	
	// HTML Version
	$msg .= "--" . $htmlalt_mime_boundary . $eol;
	$msg .= "Content-Type: text/html; charset=iso-8859-1" . $eol;
	$msg .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
	$msg .= $body . $eol . $eol;
 
	// Close the html/plain text alternate portion
	$msg .= "--" . $htmlalt_mime_boundary . "--" . $eol . $eol;
	
	// Finish with two eol's for better security.
	$msg .= "--" . $mime_boundary . "--" . $eol . $eol;  
	
	// Send the email
	mail($emailUser, $subject, $msg, $headers);
	mail($emailAdmin, $subject, $msg, $headers);
 
?>

Open in new window

0
 
LVL 17

Assisted Solution

by:nplib
nplib earned 500 total points
ID: 20376823
i like phpmailer
http://phpmailer.codeworxtech.com/

it's very simple to use.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question