Jump to content

404

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by 404

  1. Thanks ...I guess that should have been obvious 🙂. Do you know of a tutorial somewhere online that would help me with adding the proper validation?
  2. Thanks for responding. I made a typo in the code ...it's working now . The only thing that doesn't seem to work is the error section at the bottom of the PHP code (which I left out in my previous post - oops!). If the sender doesn't fill out any field correctly or even leaves it blank, the form sends the message anyway. Here's the missing bit of PHP: } else { ?> <script language="javascript" type="text/javascript"> alert('Message failed. Please try again or contact us directly by phone.'); window.location = 'index.html'; </script> <?php } ?>
  3. I'm working on a Contact Form for my website. It works, except the "Phone" field doesn't show a phone number in the sent message. It's just blank where the number should be displayed. What am I doing wrong? - Thanks HTML: <div class="contact-form"> <h2 class="style">Contact Us</h2> <form action="contact.php" method="post" id="form"> <div> <span><label>NAME</label></span> <span><input name="cf_name" type="text" class="textbox"></span> </div> <div> <span><label>EMAIL</label></span> <span><input name="cf_email" type="text" class="textbox"></span> </div> <div> <span><label>PHONE</label></span> <span><input name="cf_phone" type="text" class="textbox"></span> </div> <div> <span><label>MESSAGE</label></span> <span><textarea name="cf_message"> </textarea></span> </div> <div> <span><input type="submit" value="Send"></span> </div> </form> </div> PHP: <?php $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_phone = $_POST['cf_phone']; $field_message = $_POST['cf_message']; $mail_to = 'somebody@invalid.com'; $subject = 'Message from a website visitor '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\n"; $body_message .= 'Phone: '.$field_phone."\n"; $body_message .= 'Message: '.$field_message; $headers = 'From: '.$field_email."\r\n"; $headers .= 'Reply-To: '.$field_email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. We will contact you shortly.'); window.location = 'index.html'; </script> <?php
×
×
  • Create New...