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 = "[email protected]";

 

/* 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 <[email protected]>\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
https://forums.phpfreaks.com/topic/58681-forms/
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 = "[email protected]";
   
   /* 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 <[email protected]>\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
https://forums.phpfreaks.com/topic/58681-forms/#findComment-291102
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.