-1

I haven't written code in years, so I am going off old code from a project that is over 5 years old, so I am not surprised that it doesn't work; I would like some pointers on how to make it work, please.

Here is what I have in my HTML email form --

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

                                                <div class="form-group">
                                                    <!--<label for="contact_name">Name:</label>-->
                                                    <input type="text" id="contact_name" class="form-control" placeholder="Name" />
                                                </div>
                                                <div class="form-group">
                                                    <!--<label for="contact_email">Email:</label>-->
                                                    <input type="text" id="contact_email" class="form-control" placeholder="Email Address" />
                                                </div>
                                                <div class="form-group">
                                                    <!--<label for="contact_message">Message:</label>-->
                                                    <textarea id="contact_message" class="form-control" rows="9" placeholder="Write a message"></textarea>
                                                </div>
                                                <button type="submit" class="btn btn-primary">Send</button>

                                        </form>

and here is what my PHP looks like --

 <?php

if(isset($_POST['send'])) {
   // Prepare the email
$to = ''foryourdayformals@gmail.com ';

$name = $_POST['contact_name'];
$mail_from = $_POST['contact_email'];
   $subject = 'Message sent from website';
   $message = $_POST['contact_message'];

$header = "From: $name <$mail_from>";

   // Send it
   $sent = mail($to, $subject, $message, $header);
   if($sent) {
   echo 'Your message has been sent successfully! <a href="http://www.foryourdayllc.com">Return to For Your Day, LLC Website</a>';
   } else {
   echo 'Sorry, your message could not send. Please use direct email link on Contact Us page (below the map). <a href="http://www.foryourdayllc.com">Return to For Your Day, LLC Website</a>';
   }
}
?>

Any help is GREATLY appreciated! Thanks!

steamfunk
  • 3
  • 1
  • `$to = ''foryourdayformals@gmail.com ';` that's an error right there; look at syntax highlighting. – Funk Forty Niner Apr 05 '17 at 15:00
  • and this `if(isset($_POST['send'])) {...}` will never fire and you have no name attributes. – Funk Forty Niner Apr 05 '17 at 15:00
  • Thank you so much! I should smack myself for missing things that were so simple. Yet I am glad that it was just that easy, maybe I am not as rusty at coding as I thought... Again, a million thanks! – steamfunk Apr 05 '17 at 16:19

1 Answers1

0

update

$to = ''foryourdayformals@gmail.com ';

to

$to = 'foryourdayformals@gmail.com';

and need to add name attribute for form . This update your form

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

                                                <div class="form-group">
                                                    <!--<label for="contact_name">Name:</label>-->
                                                    <input type="text" id="contact_name" name="contact_name" class="form-control" placeholder="Name" />
                                                </div>
                                                <div class="form-group">
                                                    <!--<label for="contact_email">Email:</label>-->
                                                    <input type="text" id="contact_email" name="contact_email" class="form-control" placeholder="Email Address" />
                                                </div>
                                                <div class="form-group">
                                                    <!--<label for="contact_message">Message:</label>-->
                                                    <textarea id="contact_message" name="contact_message" class="form-control" rows="9" placeholder="Write a message"></textarea>
                                                </div>
                                                <button type="submit" class="btn btn-primary" name ="send">Send</button>

                                        </form>
Shafiqul Islam
  • 5,570
  • 2
  • 34
  • 43
  • Thank you so much! I should smack myself for missing things that were so simple. Yet I am glad that it was just that easy, maybe I am not as rusty at coding as I thought... Again, a million thanks! – steamfunk Apr 05 '17 at 16:19