0

IF (I Started Receiving Spam Bot Forms)

THEN (I Implemented New PHP Email script using a basic Honey Pot Method)

$ERROR (New PHP is not sending ALL the forms fields. Upon sending the form, my email is only receiving the, textarea id="message", field)

$LOG_FILE (My previous PHP script implemented a dynamic catch-all solution for form fields)

$FAILED_SOLUTION (Conversely I attempted to add the individual, $phone & $address fields manually on lines #6 7 & 14 of the PHP but am still only receiving the, textarea id="message", field)

$NOTES (I am self taught & typically only deal with PHP on a need to know basis. Please try to keep it simple and include a step-by-step explanation. Feel free to suggest any "best practices" i may have overlooked unrelated to my problem!)

$QUESTION = "Can someone show me how to call the other form fields in the PHP script to send to my email?"

$SUCCESS = "Thanks in Advance For Any Help That Maybe Given!";

PHP:

<?php
if($_POST){
$to = '[email protected]';
$subject = 'Contact Form Submission';
$name = $_POST['name'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$email = $_POST['email'];
$message = $_POST['message'];
$robotest = $_POST['robotest'];
if($robotest)
  $error = "Spam Protection Enabled";
else{
  if($name && $phone && $address && $email && $message){
    $header = "From: $name <$email>";
    if(mail($to, $subject, $message,$header))
      $success = "Your message was sent!";
    else
      $error = "Error_36 there was a problem sending the e-mail.";
  }else
    $error = "Error_09 All fields are required.";
}
if($error)
  echo '<div class="msg error">'.$error.'</div>';
elseif($success)
  echo '<div class="msg success">'.$success.'</div>';
}
?>

HTML FORM:

<form method="post" action="Form_Email.php">
    <input type="text" id="name" name="name" placeholder="name" required>
    <input type="text" id="phone" name="phone" placeholder="phone" required>
    <input type="text" id="address" name="address" placeholder="address" required>
    <input type="text" id="email" name="email" placeholder="email" required>                            
    <textarea id="message" name="message" placeholder="message" required> </textarea>
<p class="robotic">
    <input name="robotest" type="text" id="robotest" class="robotest" autocomplete="off"/>
</p>
    <input type="submit" id="SEND" value="Submit">
</form> 
5
  • Can you write out your question? Commented Apr 26, 2017 at 3:04
  • 2
    you only sending this variable $message only not others .so need to concatenate which is you want to send . Commented Apr 26, 2017 at 3:04
  • @chris85 question added to my post for clarification Commented Apr 26, 2017 at 3:23
  • 1
    Just a hint, if you detect spam, don't tell them you detect spam .Tell them it worked perfectly, but do not send. Commented Apr 26, 2017 at 5:05
  • 1
    Okay, so you just need to concatenate your other variables with $message. $message is the only thing you are sending. mail($to, $subject, $message,$header). Commented Apr 26, 2017 at 12:02

1 Answer 1

1

Your message contains only $_POST['message'] for now. If you want to append other values, use concatenation on your $message variable.

$message .= ($name . $phone . $address . $etc)

Notice: A $foo .= $bar construction stands for $foo = $foo . $bar.

Do not forget about whitesigns such as spaces or new lines wherever you want. Simply concatenate ' ' or "\n".

After that, just send a mail using your $message as message.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.