Dear Admin,
";
$body.="
Message from : $username
";
$body.="
Email id : $email
";
$body.="
Message : $msg
";
$body.="Feedback end";
if(@mail($to,'feedback from http://programming-in-php.blogspot.com',$body,$headers))
{
echo "Thank you for your valuable feedback !";
}
else
{
echo "
Can't send email ! ! !
";
}
}
?>
Finally, merge all the code to create a simple contact us form or feedback form.
Full source code is here for your reference
.textbox,.textarea {
width:300px;
border:solid 2px #00CCFF;
padding:3px;
margin:10px;
}
.error {
background: #FBBFDC;
color:#EF013D;
border:solid 1px;
padding:5px;
margin:5px;
}
if(isset($_POST["Submit"]))
{
$email = $_POST["email"];
$msg = $_POST["message"];
$username = $_POST["name"];
if($username!="" and $email!="" and $msg!="")
{
sendmail($username,$email,"",$msg,"");
}
else
{
echo "
Fill all the fields ! Thank you.
";
}
}
function sendmail($username,$email,$data,$msg,$footer)
{
$to="youremailidhere";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//$headers .= "From: ".$from."\r\n";
$headers .= "From: $username <$email>\r\n";
$headers .= "Reply-To: youremailidhere\r\n";
$body="
Dear Admin,
";
$body.="
Message from : $username
";
$body.="
Email id : $email
";
$body.="
Message : $msg
";
$body.="Feedback end";
if(@mail($to,'feedback from http://programming-in-php.blogspot.com',$body,$headers))
{
echo "Thank you for your valuable feedback !";
}
else
{
echo "
Can't send email ! ! !
";
}
}
?>
I'm reading: Send Feedback or contact via mail function in phpTweet this!