web blazonry web development scripts and tutorials Get best price on Unlocked Galaxy S20 5G
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   




PHP Name Generators
  Wu-Name
  U.S. Name
  Baby Name

Bookmark and Share




Collect Feedback And Email It To Yourself

This coding example shows how to collect feedback from your site using a form and email the response to yourself.

The first thing we need is the HTML form. Keeping it simple for this example, I ask for only name, email and feedback. The HTML for the form is in the source code.

Try the form below to see how the user interface works. You won't really send me an email because that would generate too much email for me.


Name:
Email:
Feedback:


PHP Code That Sends the Email
The PHP code to send email is the PHP function mail(). The basic format for this function is:

mail("to", "subject", "message");

For example, (this is straight out of the online PHP documentation:

mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3");

PHP needs to be installed and setup properly to send mail from the server. On a Unix-type setup such as Linux, PHP uses your local sendmail program. Windows machines use SMTP. If you need to, edit your php.ini file and set the appropiate SMTP host to send email.

Here's the code to send the email:

<?
if ($_SERVER['REQUEST_METHOD'] == "POST") {
  
// Just to be safe, I strip out HTML tags   
$realname = strip_tags($realname);   
$email = strip_tags($email);   
$feedback = strip_tags($feedback);   
  
// set the variables   
// replace $me@mysite.com with your email   
$sendto = "$me@mysite.com";   
$subject = "Sending Email Feedback From My Website";   
$message = "$realname, $email\n\n$feedback";   
  
// send the email   
mail($sendto, $subject, $message);   

}   
?>

View the source code. (phpmail.phps)

 

 

Newest Pages
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources
 
 

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.