I have a Contact Form on the homepage of my WordPress website.
The 'Send' button doesn't do anything.
Below is the code we're using.
contact_process.php:
mail.php:
And here's the corresponding code placed on my homepage:
Question is - why isn't my 'Send' button functioning? It does nothing when I click on it.
I'll pay $5 USD via PayPal to whoever can figure this one out.
Thanks.
The 'Send' button doesn't do anything.
Below is the code we're using.
contact_process.php:
Code:
<?php
include dirname(dirname(__FILE__)).'/mail.php';
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
//$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);
$error = '';
// Check name
if(!$name)
{
$error .= 'Please enter your name.<br />';
}
// Check email
if(!$email)
{
$error .= 'Please enter an e-mail address.<br />';
}
if($email && !ValidateEmail($email))
{
$error .= 'Please enter a valid e-mail address.<br />';
}
// Check message (length)
if(!$message || strlen($message) < 10)
{
$error .= "Please enter your message. It should have at least 10 characters.<br />";
}
if(!$error)
{
$mail = mail(CONTACT_FORM, 'Contact form by: '.$name, $message,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail)
{
echo 'OK';
}
}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}
}
function ValidateEmail($value)
{
$regex = '/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i';
if($value == '') {
return false;
} else {
$string = preg_replace($regex, '', $value);
}
return empty($string) ? true : false;
}
?>
mail.php:
Code:
<?php
// Where will you get the forms' results?
define("CONTACT_FORM", '[email protected]');
?>
And here's the corresponding code placed on my homepage:
Code:
<div class="slide" id="slide5" data-slide="5" data-stellar-background-ratio="0.5">
<div class="container clearfix">
<h1><span><?php echo $data['contact_us_heading']; ?></span></h1>
<div class="page_excerpt"><?php echo nl2br(stripslashes($data['contact_us_text'])); ?></div>
<div class="contact_block">
<div class="grid_12">
<div class="contact_form">
<div id="note"></div>
<div id="fields">
<form id="ajax-contact-form" action="">
<span class="float_left"><input type="text" name="name" value="" placeholder="Name" /></span>
<span class="float_right"><input type="text" name="email" value="" placeholder="Email" /></span>
<div class="clear"></div>
<textarea name="message" id="message" placeholder="Message"></textarea>
<div class="clear"></div>
<input type="reset" class="contact_btn" value="Clear Form" />
<input type="submit" class="contact_btn send_btn" value="Send" />
<div class="clear"></div>
</form>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
Question is - why isn't my 'Send' button functioning? It does nothing when I click on it.
I'll pay $5 USD via PayPal to whoever can figure this one out.
Thanks.







