2012-09-30, 05:41 PM
I understand this is outside of mybb, but i know that mybb must use a similar way for contacting
Below is my contact form for my website... When a field is left empty, it doesn't display the alert message correctly, it just says "NaN"
help please
Below is my contact form for my website... When a field is left empty, it doesn't display the alert message correctly, it just says "NaN"
help please
<?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);
// EMPTY FIELD CHECK
if( (empty($field_name)) || (empty($field_email)) || (empty($field_message)) ) { ?>
<script language="javascript" type="text/javascript">
alert("Fields marked with a "*" are required. You will be redirected shortly");
window.location = 'http://www.imatthew.webege.com/contact';
</script>
<?php
}
// SUCCESS
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'http://www.imatthew.webege.com/contact';
</script>
<?php
}
// FAILURE
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to [email protected]');
window.location = 'http://www.imatthew.webege.com/contact';
</script>
<?php
}
?>