ZappyLawns Posted April 20, 2014 Share Posted April 20, 2014 I can get it to work but it looks ugly. If I get it to look pretty it doesn't work. Please help me fix it and make it stay the same. Html Code: <h3>Contact Form</h3> <form id="ContactForm" action="contact.php" method="post"> <div> <div class="wrapper"> <span>Your Name:</span> <input type="text" class="input" name="cf_name" > </div> <div class="wrapper"> <span>Your E-mail:</span> <input type="text" class="input" name="cf_email"> </div> <div class="textarea_box"> <span>Your Message:</span> <textarea name="cf_message" cols="1" rows="1"></textarea> </div> <a href="#" class="button1">Send</a> <a href="#" class="button1">Clear</a> </div> </form> Then The Php: $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_message = $_POST['cf_message']; <?php $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_message = $_POST['cf_message']; $mail_to = '[email protected]'; $subject = 'Message from a site visitor '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\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 = 'contact_page.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('Message failed. Please, send an email to [email protected]'); window.location = 'contact_page.html'; </script> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/287903-contact-form-help/ Share on other sites More sharing options...
denno020 Posted April 20, 2014 Share Posted April 20, 2014 Can you show us the 'pretty' version that doesn't work? Also, you're trying to set php variables and read from $_POST before you've opened the <?php tags. Link to comment https://forums.phpfreaks.com/topic/287903-contact-form-help/#findComment-1476809 Share on other sites More sharing options...
bsmither Posted April 20, 2014 Share Posted April 20, 2014 I don't like this: <a href="#" class="button1">Send</a> <a href="#" class="button1">Clear</a> There is nothing to differentiate the two links. I would expect some javascript to actually submit the form, looking at these <a> tags for a click event. Link to comment https://forums.phpfreaks.com/topic/287903-contact-form-help/#findComment-1476810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.