Jump to content

Contact Form Help


ZappyLawns

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.