Jump to content

Forms


FevFan

Recommended Posts

Hiya,

 

I've been reading through a fair few topics on here about contact us forms and there is nothing conclusive. I have built a contact form and i've tested it says its sent but i never get the email, i've changed the email reciepent from a hotmail address to my work account and i still don't recieve the email.

 

Can you help me please.

 

Here is my script.

Contact_form.php

 

<form method="post" action="fevmail.php">

  Name:-<br />

  <input name="name" type="text" size="25"><br />

  Email:-<br /><input name="email" type="text" size="25"><br />

Message:-<br />

<textarea name="message" cols="50" rows="2"></textarea>

  <br /><input type="submit" name="submit_button" value="submit">

  <input name="good_url" type="hidden" id="good_url" value="thanks.php" />

</form>

 

fevmail.php

 

<?php

 

/*

INSTRUCTIONS FOR USE

 

1. Install this script in your Root directory (save it as mail.php)

2. Create a form and insert one hidden field, called "good_url" with a value of e.g. thankyou.htm/ thankyou.php or any other page you wish to call it (you will create this thankyou page next)

3. Make the ACTION of the form point to this page

4. Create a thankyou.htm/ thankyou.php page (the same name as your "good_url" [item 2 above]).

5. Amend the config section below and change the 'YOUR_EMAIL_ADDRESS' to your email address (where you wish to pick up the form results!

 

*/

 

/*

CONFIG

Set the line

$_email_recipient = "YOUR_EMAIL_ADDRESS";

where YOUR_EMAIL_ADDRESS is your email address!!

*/

 

$_email_recipient = "chris@codefarm.co.uk";

 

/* end fo config */

 

 

 

 

 

 

 

$_referer = $_SERVER['HTTP_REFERER'];

 

$_this_server = "http:\/\/" . $_SERVER['SERVER_NAME'];

 

if (preg_match ("/^" . $_this_server . "/", $_referer)){

 

foreach ($_POST as $_key => $_value){

 

if ($_key == "good_url"){

 

$_good_url = $_value;

 

} else {

 

$_message .= "$_key: $_value<br/>";

 

}

 

}

 

$_subject = "Generated email from: $_referer";

 

// To send HTML mail, the Content-type header must be set

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

// Additional headers

$headers .= "To: $_email_recipient <$_email_recipient>\r\n";

$headers .= "From: Your Website <donotreply@mysite.com>\r\n";

 

if (file_exists ($_good_url)){

 

if (@mail ($_email_recipient, $_subject, $_message, $headers)){

 

header ("location:$_good_url");

 

} else {

 

print ("Could not send email to: $_email_recipient");

 

}

 

} else {

 

print ("Please specify a valid 'good_url'");

 

}

 

}

 

exit;

 

?>

 

thanks.php

 

<h1>THANKS!!

</h1>

 

Link to comment
Share on other sites

<form method="post" action="fevmail.php">
   Name:-

   <input name="name" type="text" size="25">

   Email:-
<input name="email" type="text" size="25">

Message:-

<textarea name="message" cols="50" rows="2"></textarea>
   
<input type="submit" name="submit_button" value="submit">
   <input name="good_url" type="hidden" id="good_url" value="thanks.php" />
</form>

 

<?php

   /*
   INSTRUCTIONS FOR USE
   
   1. Install this script in your Root directory (save it as mail.php)
   2. Create a form and insert one hidden field, called "good_url" with a value of e.g. thankyou.htm/ thankyou.php or any other page you wish to call it (you will create this thankyou page next)
   3. Make the ACTION of the form point to this page
   4. Create a thankyou.htm/ thankyou.php page (the same name as your "good_url" [item 2 above]).
   5. Amend the config section below and change the 'YOUR_EMAIL_ADDRESS' to your email address (where you wish to pick up the form results!
   
   */
   
   /*
   CONFIG
   Set the line
   $_email_recipient = "YOUR_EMAIL_ADDRESS";
   where YOUR_EMAIL_ADDRESS is your email address!!
   */
   
   $_email_recipient = "chris@codefarm.co.uk";
   
   /* end fo config */
   
   
   
   
   
   
   
   $_referer = $_SERVER['HTTP_REFERER'];
   
   $_this_server = "http:\/\/" . $_SERVER['SERVER_NAME'];
   
   if (preg_match ("/^" . $_this_server . "/", $_referer)){
      
      foreach ($_POST as $_key => $_value){
         
         if ($_key == "good_url"){
            
            $_good_url = $_value;
            
         } else {
         
            $_message .= "$_key: $_value
";
            
         }
         
      }
      
      $_subject = "Generated email from: $_referer";
      
      // To send HTML mail, the Content-type header must be set
      $headers  = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      
      // Additional headers
      $headers .= "To: $_email_recipient <$_email_recipient>\r\n";
      $headers .= "From: Your Website <donotreply@mysite.com>\r\n";
            
      if (file_exists ($_good_url)){
      
         if (@mail ($_email_recipient, $_subject, $_message, $headers)){
         
            header ("location:$_good_url");
            
         } else {
         
            print ("Could not send email to: $_email_recipient");
            
         }
         
      } else {
            
         print ("Please specify a valid 'good_url'");
         
      }
      
   }
   
   exit;
   
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.