Hello,
I have this contact form website
Try to fill in the whole information then after you press submit, the next page start to hang. Why is it?
<?php
// FORM VALIDATION AND RECAPTCHA SETTING
// Include ReCaptcha and define keys
require_once('recaptchalib.php');
define('RECAPTCHA_PUBLIC', '6LdRStUSAAAAAH4f_NMg-Fmdp2bDo4LYNhN36ScB');
define('RECAPTCHA_PRIVATE', '6LdRStUSAAAAABctjZq_iX249auG_kjaNvn_4vfN');
// Define notification recipient
define('NOTIFICATION_RECIPIENT', 'davy_yg@yahoo.com');
// Define data and error arrays
$data = array('name' => '', 'email' => '', 'phone' => '', 'message' => '', 'captcha' => '');
$errors = array();
$error = '';
// Check if form submitted
if($_POST) {
// Prepare form data and captcha
$data = array_merge($data, $_POST['form']);
$captcha = recaptcha_check_answer(RECAPTCHA_PRIVATE, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
// Validate name
if(strlen(trim($data['name'])) == 0)
$errors['name'] = 'Name is mandatory';
// Validate email
if(strlen(trim($data['email'])) == 0)
$errors['email'] = 'Email is mandatory';
elseif(! filter_var($data['email'], FILTER_VALIDATE_EMAIL))
$errors['email'] = 'Email is not valid';
// Validate phone
if(strlen(trim($data['phone'])) == 0)
$errors['phone'] = 'Phone is mandatory';
// Validate message
if(strlen(trim($data['message'])) == 0)
$errors['message'] = 'Message is mandatory';
// Validate captcha
if(! $captcha->is_valid)
$errors['captcha'] = 'Captcha is incorrect';
// Send email and redirect user if no form errors
if(! $errors) {
if(send_notification($data))
header('Location: thank-you.php');
else
$error = 'An unexpected error occurred. Please try again.';
}
}
?>
<div id="form">
<form method="post" action="konsultasi-konsumen.php">
<?php if($error): ?>
<h3><?php echo $error; ?></h3>
<?php endif; ?>
<table border="0">
<tr align="left">
<th><div class="form-row">
<label for="name">Name</label><br /></th>
<th><input id="name" type="text" name="form[name]" value="<?php echo $data['name']; ?>" />
<?php if(isset($errors['name'])): ?>
<span class="form-error"><?php echo $errors['name']; ?></span>
<?php endif; ?>
</div></th>
</tr>
<tr align="left">
<th><div class="form-row">
<label for="email">Email</label><br /></th>
<th><input id="email" type="text" name="form[email]" value="<?php echo $data['email']; ?>" />
<?php if(isset($errors['email'])): ?>
<span class="form-error"><?php echo $errors['email']; ?></span>
<?php endif; ?>
</div></th>
</tr>
<tr align="left">
<th><div class="form-row">
<label for="name">Phone</label><br /></th>
<th><input id="name" type="text" name="form[phone]" value="<?php echo $data['phone']; ?>" />
<?php if(isset($errors['phone'])): ?>
<span class="form-error"><?php echo $errors['phone']; ?></span>
<?php endif; ?>
</div></th>
</tr>
<tr align="left">
<th><div class="form-row">
<label for="message">Message</label><br /></th>
<th><textarea id="message" name="form[message]"><?php echo $data['message']; ?></textarea>
<?php if(isset($errors['message'])): ?>
<span class="form-error"><?php echo $errors['message']; ?></span>
<?php endif; ?>
</div></th>
</tr>
<tr><th><br></th></tr>
<tr align="left">
<th colspan="2"><div class="form-row">
<?php echo recaptcha_get_html(RECAPTCHA_PUBLIC); ?>
<?php if(isset($errors['captcha'])): ?>
<span class="form-error"><?php echo $errors['captcha']; ?></span>
<?php endif; ?>
</div></tr>
<tr align="left">
<th colspan="2"><div class="form-row">
<input type="submit" value="Submit" />
</div></th></tr>
</table>
</form>
</div>