Get best price on Unlocked Galaxy S20 5G | ||||||||||||
|
||||||||||||
|
Collect Feedback And Email It To YourselfThis 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.
PHP Code That Sends the Email
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)
|
privacy policy || © 1997-2016. astonishinc.com All Rights Reserved. |