Hey I'm having troubles getting my PHP Form to work... Will send $5 to whoever can correct it. The problem is I'm not getting anything in my email CONTACT.HTML <form id="contact" method="POST" action="thanks.php"> <fieldset> <label for="name" id="name_label">Name<span class="red">*</span></label> <input type="text" name="name" id="name" size="50" value="" class="text-input" /> <label for="email" id="email_label">E-mail<span class="red">*</span></label> <input type="text" name="email" id="email" size="50" value="" class="text-input" /> <label for="website" id="website_label">Website</label> <input type="text" name="website" id="website" value="http://www." class="text-input" /> <label for="msg" id="msg_label">Message<span class="red">*</span></label> <textarea cols="60" rows="10" name="msg" id="msg" class="text-input"></textarea> <br /> <input type="submit" name="submit" class="button" id="submit_btn" value="Send Message"/><br /> <span class="error" id="name_error">Please enter name !</span> <span class="error" id="email_error">Please enter email address !</span> <span class="error" id="email_error2">Please enter valid email address !</span> <span class="error" id="msg_error">Please enter message !</span> </fieldset> </form> Code (markup): THANKS.PHP <?php if(isset($_POST['submit'])) { $to = "myemail@email.com"; $subject = "Quote"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['website']; $message1 = $_POST['msg']; $body = "Full Name: $name_field\n E-Mail: $email_field\n Website: $message\n Message: $message1\n "; mail($to, $subject, $body); } else { echo "blarg!"; } ?> Code (markup): Someone please help... REP + $5
Try this: <?php if(isset($_POST['submit'])) { $to = '"Company Name" <myemail@email.com>'; $subject = 'Quote'; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['website']; $message1 = $_POST['msg']; $body = "Full Name: $name_field\n E-Mail: $email_field\n Website: $message\n Message: $message1\n "; $headers = 'From: "Your WebSite" <site@domain.com>' . PHP_EOL . 'X-Mailer: PHP-' . phpversion() . PHP_EOL; if (mail($to, $subject, $body, $headers)) { echo 'mail() Success!' . "<br />\n"; } else { echo 'mail() Failure!' . "<br />\n"; } } ?> PHP:
This didn't fix the problem either. My hosting said It's a problem on my end. I checked my junk folder, still nothing. It seems when I press "submit" it just stays on the same page. It doesn't go to the process page.
I guess all you can do is to change your hosting provider - there is nothing wrong with the code you have posted here.
If your e-mail hosting requires authentication, that code wont work. Why would a server farm allow non-authenticated e-mails to be sent out from it? Look for the PHP mail PEAR module.