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: <?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; } ?> Code (markup): mail.php: <?php // Where will you get the forms' results? define("CONTACT_FORM", 'you@email.com'); ?> Code (markup): And here's the corresponding code placed on my homepage: <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> Code (markup): 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.
HELLo, Right after <form id="ajax-contact-form" action=""> HTML: enter <input type="hidden" name="action" value="newFormMail" /> HTML: In your PHP, remove $post = (!empty($_POST)) ? true : false; PHP: and replace if($post) Code (markup): with if(@$_POST['action'] == 'newFormMail') Code (markup): You also need to set the action="". If your at example.com/contact.php then it needs to be set to <form action="/contact.php" method="post"> HTML: This should at least give you a response when you press the button. But if form will actually work is another question Let me know if you have any more work that needs doing.
its an ajax form u dont need to put contact.php, js handle it and call the php function contact_process.php . There a problem somewhere .
There is absolutely no indication that this is an ajax form. And as far as i can see, then this is pure PHP.
I'm sorry, but non the less. If you do use javascript with this code, then i can understand why it's not working. Your missing the javascript. If you want to send the form trough javascript, then the PHP content needs to be in a separate file from the HTML. The form submit button must then be activated by javascript and the form either serialized or retrieve the form values manually and push them to the PHP file. If your statement is true and this code is based on ajax and the submit button does "nothing". Then, considering that Javascript is what activates the form, i would say that posting your javascript code is vital. Edit: It kind of makes sense that you use js based on your isset, but besides that. Absolutely nothing buddy Submit your JS code and it might be possible to solve your problem.