-3

I'm relatively new at coding and I've run into an issue. When I submit the filled out data in the form to my email, it won't submit the name or phone number so I essentially see it as a random, authorless message in my inbox. For obvious reasons, I need to capture and send ALL the data from the form to the specified email. I've used up all my knowledge so hopefully someone can help.

TLDR; Form sends an email, but not with ALL the filled out information

Thanks

HTML:

<form id="contact" action="send.php" method="post">
<fieldset>
  <input placeholder="Your name" type="text" name="name" tabindex="1" autofocus>
</fieldset>
<fieldset>
  <input placeholder="Your Email Address" type="text" name="email" tabindex="2">
</fieldset>
<fieldset>
  <input placeholder="Your Phone Number" type="text" name"phone" tabindex="3">
</fieldset>

<fieldset>
  <textarea placeholder="Type your Message Here...." type="text" name="message" tabindex="5"></textarea>
</fieldset>
<fieldset>
  <button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit</button>
</fieldset>

PHP:

    <?php
$from="noreply@email.com";
$email="my email";
$name=$_POST['name'];
$phone=$_POST['phone'];
$subject=$_POST['subject'];
$message=$_POST['message'];

mail ( $email, $subject, $message, "From:".$from);

Print "Thank you! Your message has been sent!"

?>
  • 3
    How did you expect `$phone` to appear if you don't include it? Any further tries to show? – mario Sep 22 '17 at 19:04
  • As I said, I'm pretty new to all of this so I apologize if this is a stupid question.. what do you mean by "include it"? – itschriswtf Sep 22 '17 at 19:06
  • you send all extra info into $message by concatenating . Ofcourse you not all using $phone any where. – RamaKrishna Sep 22 '17 at 19:08

1 Answers1

0

While you are defining the variables, you are not actually including them in the email sent, like this:

<?php
$from="noreply@email.com";
$email="my email";
$name=$_POST['name'];
$phone=$_POST['phone'];
$subject=$_POST['subject'];
$message=$_POST['message'];

$message = "$message\r\n$name\r\n$phone";

mail ($email, $subject, $message, "From: $from");

echo("Thank you! Your message has been sent!");

?>
mario
  • 144,265
  • 20
  • 237
  • 291
The Codesee
  • 3,714
  • 5
  • 38
  • 78