0

I have a form, and I don't know why I can't receive a single email, I used to but now I can't...

<!DOCTYPE HTML>
<?php
  require_once('recaptchalib.php');
  $privatekey = "MY-PRIVATE-KEY";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);
?>

<?php
$fn = $_POST['fn'];
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
mail($to, $subject, $message, $headers);
$to = "myemail@gmail.com";
$subject = "Form Submission";
    $headers = "From: " . strip_tags($_POST["req-email"]) . "\r\n";
    $headers .= "Reply-To: ". strip_tags($_POST["req-email"]) . "\r\n";
    $headers .= "CC: email2@gmail.com\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content=Type: text/html; charset=ISO-8859-1\r\n";
    $message = "<html><head>";
    $message = "<style>";
    $message = "h1 {color:#blue;}";
    $message = "table {border:1px solid black;}";
    $message = "</style></head><body>";
    $message = "<h1>Hello, this form has been submitted!</h1>";
    $message .= '<img src= "logo.png" />';
    $message .= '<table rules="all" style="border-color: #ffb300;" cellpadding="10">';
    $message .= '<tr style="background: #ffb300;"><td><strong>Name:</strong> </td><td>' . strip_tags($_POST['req-name']) . '</td></tr>';
    $message .= '<tr><td><strong>Email:</strong> </td><td>' . strip_tags($_POST['req-email']) . '</td></tr>';
    $message .= '<tr><td><strong>Phone:</strong> </td><td>' . strip_tags($_POST['req-phone']) . '</td></tr>';
    $message .= '<tr><td><strong>Comments:</strong> </td><td>' .strip_tags($_POST['comments']) . '</td></tr>';
$message .= "</table>";
$message .= "</body></html>";
?>


<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("myemail@gmail.com", $subject,
  $message, "From:" . $email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
<script type="text/javascript">
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
</script>
</head>

<body>
      <input name="name" type="text" id="name" onBlur="MM_validateForm('name','','R','lastname','','R','email','','RisEmail','phone','','RisNum','message','','R');return document.MM_returnValue" size="55" placeholder="First Name"><br>
<input name="lastname" type="text" size="55" id="lastname" placeholder="Last Name"><br>  
<input name="email" type="text" id="email" size="55" placeholder="Email"><br>  
<input name="phone" type="text" id="phone" size="55" placeholder="Phone"><br>  
<label>Reason For Contact</label><br>  
<textarea name="message" id="message" rows="4" cols="40"></textarea><br>
    <form action="" method="post">

<form>
 <?php print (isset($errors) ? $errors : ''); ?>
</form>

      <form method="post" action="http://mysite.com/recaptcha.php">
        <?php
          require_once('recaptchalib.php');
          $publickey = "MY-PUBLIC-KEY"; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        ?>

        <input type="submit" name="submit1" value="Submit" />
      </form>
<?php
$fn = $_POST['fn'];
$lastname = $_POST['lastname'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
//$emailMe = (isset($_POST['emailMe'])) ? $_POST['emailMe'] : 'No';
//validate
if(empty($fn) || empty($name) || empty($lastname) || empty($email) || empty($phone)){
$message = 'Fill in areas in red!';
$aClass = 'errorClass';}
$cvsData = $fn . "," . $name . "," . $lastname . "," . $email . "," . $phone . "," . $comments . "\n";
$fp = fopen("cf_menu.csv", "a" );
if($fp){
    fwrite($fp, $cvsData);
    fclose($fp);
    }
?>

</body>
</html>
2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by mmcdonald
0

I don't suppose your mail server has changed or has an error? I know you put gmail above but that might just be to hide your domain :)

Also if (isset($_REQUEST['email'])) should not be used now as it has compatability issues with IE and possibly other browsers.

Instead use if (isset($_POST["button_id"])=="button_value")

in your case this would be if (isset($_POST["submit1"])=="Submit")

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.