Email via HTML form

Source: Internet
Author: User
Tags html form
As follows:
?

/******************************************************************************
Description:this is a simple script to send emails via a html-form
to different users
date:1999-02-25
Author:amalesh Kempf <amalesh@goatrance.de>


Create This table
The field "What" is for different categories

CREATE TABLE email_notify (
ID Int (one) DEFAULT ' 0 ' not NULL,
What varchar DEFAULT ' 0 ' not NULL,
Name varchar DEFAULT ' 0 ' not NULL,
Email varchar DEFAULT ' 0 ' not NULL,
Timestamp varchar (16),
KEY (What),
PRIMARY KEY (ID));

To fill this table for might create an insert form

*******************************************************************************/




Set This values:
$strHost = "localhost";
$strUser = "root";
$STRPASSW = "";
$strSender = "you@domain.com";



if (! $btnSendEmail)
{
?>

The email is added automatically with ' Hello Name ' in the '
The emailbody!<br>
<br>

<form action= "send_email.php3" enctype= "application/x-www-form-
urlencoded "method=" POST ">
<table>
<tr>
<td>Subject</td>
<td><input name= "Strsubject" size= "></td>"
</tr>
<tr>
<td>Body</td>
<td><textarea cols= "Name=" "Strbody" rows= "8"
wrap= "Physical" &GT;&LT;? Echo $strBody?></textarea></td>
</tr>
<tr>
<td>Category</td>
<td>
<select name= "Strwhat" >
<?php//Add your categories here:?>
<option value= "Party" >Party</option>
</select>
</td>
</tr>
</table>
<input name= "Btnsendemail" style= "HEIGHT:24PX; Width:224px "
Type= "Submit" value= "Sende Email" >
</form>

<?php
}


if (Isset ($btnSendEmail))
{echo "Send email<br>";

Create Connection
$intConID = Mysql_pconnect ($strHost, $strUser, $STRPASSW);

Header
$strHeader = "Return-path: $strSender \nerrors-to: $strSender \nfrom:
$strSender ";

Sql
$strSQL = "Select Name,email from Email_notify where LCase (what) =
' $strWhat ';
$intRes = mysql_query ($strSQL, $intConID);

echo "Send Email $strBody <br>";

Fetch array
while ($saRow = Mysql_fetch_array ($intRes))
{$strEmail = $saRow ["Email"];
$strName = $saRow ["name"];
$strBodyComplete = "Hello". $strName [$i]. "!\n\n". $strBody;

Email
Mail ($strEmail, $strSubject, $strBodyComplete, $strHeader);

Output
echo "Send to $strName <br>";
}
}
?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.