Zend - The PHP Company




Email

Add Code


email / feedback form  

Type: application
Added by: dukeoflions
Entered: 27/01/2005
Last modified: 09/12/2006
Rating: - (fewer than 3 votes)
Views: 7311
This simple email / feedback form can be used on any website with register_globals=of, so $_POST is used, also works on drupal.org installations and include files. Adds extra info: ip, address, scriptlocation and timestamp.


<?php
/////////////////////////////////////////////////////////////
// e-mail form by OpenThe.NET                              //
// Visit http://openthe.net/contact for support & questions//
/////////////////////////////////////////////////////////////
// configure to fit your needs
$to "support@opensthe.net";
$toname "Support OpenThe.NET";
$subject "e-mail from Website";
$confirm "Your e-mail has been sent!";
// for Drupal users modify the form tag the same as the alias line in the page
// do not modify below this line
if (isset($_POST['sendnow']))
{
$from $_POST['from'];
$fromname $_POST['fromname'];
$message $_POST['message'];
// extra info to add to message
$address gethostbyaddr($_SERVER['REMOTE_ADDR']);
$ip gethostbyname($_SERVER['REMOTE_ADDR']);
$timestamp time ();
$filename =  $_SERVER['PHP_SELF'];
$location $_SERVER['SERVER_NAME'].$filename;
// adding
$messagewithinfo "$messagennExtra info:nIP = $ipnAddress = $addressnTime at server = $timestampnSent with this page = $locationn";
mail($to$subject$messagewithinfo"From: $fromname <$from>rn" "Reply-To: $fromrn"X-Mailer: PHP/" phpversion());
echo(
"$confirm");
}
else
{
?>
<form name="emailform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <table width="400" border="0" cellpadding="5" cellspacing="5">
    <tr valign="top"> 
      <td width="40%">Your name:</td>
      <td width="60%"> 
        <input name="fromname" type="text" id="fromname" size="40"></td>
    </tr>
    <tr valign="top"> 
      <td>Your e-mail:</td>
      <td> 
        <input name="from" type="text" id="from" size="40"></td>
    </tr>
    <tr valign="top"> 
      <td>Your message:</td>
      <td> 
        <textarea name="message" cols="35" rows="10" id="message"></textarea></td>
    </tr>
    <tr valign="top"> 
      <td>&nbsp;</td>
      <td> 
        <input type="submit" name="sendnow" value="Send email">
      </td>
    </tr>
  </table>
</form>
<?php
};
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories