Feedback using PHP

Yesterday I discovered how to send e-mails using php. I didn’t think sending e-mails is such an easy thing. But thanks to php mail function it’s easier than one could ever imagine the code is as follows,

<?php

$to_addr = ‘you@yourdomain.com’;

if (isset($_REQUEST[‘submit’]))
{
$mail_body = ‘Name: ‘.$_REQUEST[‘name’];
$mail_body .= “\nEmail: “.$_REQUEST[’email’];
$mail_body .= “\nMessage: “.$_REQUEST[‘message’];
mail($to_addr,’Form Feedback’,$mail_body);
print “Thank you for the feedback.”;
}

else
{

print<<<_HTML_
<form method=”POST” action=”$_SERVER[PHP_SELF]”>
<table>
<tr><td>Name:</td><td><input type=”text” name=”name”></td></tr>
<tr><td>Email:</td><td><input type=”text” name=”email”></td></tr>
<tr><td>Message:</td><td><textarea name=”message”></textarea></td></tr>
<tr><td colspan=”2″><input name=”submit” type=”submit”></td></tr>
</table>
</form>

_HTML_;

}

?>

Nowerdays everybody is used to have a feedback form in their site regardless of the capacity of the site. Hope this piece of code will be useful to you. I think one could play around with this(php mail function) and come up with even more interesting applications of this, than a mere Feedback.

Let us break the barrier in sending e-mails.

Advertisements

One thought on “Feedback using PHP

Comments are closed.