Help making Captcha non case sensitive
-
Currently the captcha required to submit feedback is case sensitive. Although its not a big deal, I would prefer that it not be. Below is the code inside the contact form file. I thought it would be as easy as removing “require ‘captcha/rand.php’;” from line 8 but that didn’t seem to work. I’m at a lose. Any help is much appreciated.
<?php /* Template Name: Contact Form */ // Make the page validate //@ini_set('session.use_trans_sid', '0'); // Include the random string file require 'captcha/rand.php'; // Begin the session @session_start(); // Set the session contents if (isset($_POST['captcha'])){ if($_POST['captcha']!=$_SESSION['captcha_id']){ $_SESSION['captcha_id'] = $str; } } else{ $_SESSION['captcha_id'] = $str; } //If the form is submitted if(isset($_POST['submitted'])) { //Check to see if the honeypot captcha field was filled in if(trim($_POST['checking']) !== '') { $captchaError = true; } else { //Check to make sure that the name field is not empty if(trim($_POST['contactName']) === '') { $nameError = __('You forgot to enter your name.', 'tstranslate'); $hasError = true; } else { $name = trim($_POST['contactName']); } //Check to make sure that the =subject field is not empty if(trim($_POST['subject']) == '') { $subjectError = __('You forgot to enter the subject.', 'tstranslate'); $hasError = true; } else { $nameSub = trim($_POST['subject']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) === ''){ $emailError = __('You forgot to enter your email address.', 'tstranslate'); $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))){ $emailError = __('You entered an invalid email address.', 'tstranslate'); $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure sure that a valid captcha is submitted if(trim($_POST['captcha']) === ''){ $captchaError = __('You didn´t type the captcha.', 'tstranslate'); $hasError = true; } else if ($_SESSION['captcha_id'] != $_POST['captcha']){ $captchaError = __('You entered an invalid captcha.', 'tstranslate'); $hasError = true; } else { $_SESSION['captcha_id'] = $str; } //Check to make sure comments were entered if(trim($_POST['comments']) === ''){ $commentError = __('You forgot to enter your comments.', 'tstranslate'); $hasError = true; } else { if(function_exists('stripslashes')){ $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } //If there is no error, send the email if(!isset($hasError)){ $emailTo = get_option('themeshock_contact_mail'); $name = trim($_POST['contactName']); $subject = trim($_POST['subject']); $sendCopy = trim($_POST['sendCopy']); $body = "Name: $name \n\nEmail: $email \n\nMessage: $comments"; $headers = "From: $name <$email>" . "\r\n" . 'Reply-To: ' . $email; wp_mail($emailTo, $subject, $body, $headers); $emailSent = true; } } } get_header(); wts_tool_panel('end-layout-3'); wts_tool_panel('layout-4'); ?> <div class="wrapper_content"> <div class="lay_base content_pattern"></div> <div class="bar_separate footer_separate"></div> <div class="lay_base content_shadow"></div> <div id="content"> <div class="contact_form boxcss_3"> <h1 class="text-center"><?php the_title(); ?></h1> <?php if ( $_SERVER['HTTP_HOST']==='www.wpthemegenerator.com'):?> <style> p.info_tg{ padding:0 17px; } </style> <p class="info_tg"> This is a sample contact form that shows how the contact form will look in our themes, if you have questions please use this <a href="http://www.wpthemegenerator.com/contact/">contact form</a></p> <?php endif; if(isset($emailSent) && $emailSent == true) {?> <div class="thanks"> <h1><?php echo __('Thanks','tstranslate'); $name;?></h1> <p><?php echo __('Your email was successfully sent. I will be in touch soon.','tstranslate');?></p> </div> <?php } else { if (have_posts()) : while (have_posts()) : the_post(); if(isset($hasError) || isset($captchaError)) { ?> <p class="error"><?php echo __('There was an error submitting the form.','tstranslate');?><p> <?php } ?> <form method="post" action="<?php the_permalink();?>" id="contactForm" class="contactForm"> <table id="contact_us" align="center"> <tr> <th><?php echo __('Name','tstranslate');?></th> <td> <input name="contactName" type="text" class="requiredField" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" size="30"/> <?php if($nameError != '') {?> <span class="error"><?php echo $nameError;?></span> <?php } ?> </td> </tr> <tr> <th>E-mail</th> <td> <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="requiredField email" size="30"/> <?php if($emailError != ''){?> <span class="error"><?php echo $emailError;?></span> <?php }?> </td> </tr> <tr> <th><?php echo __('Subject','tstranslate');?></th> <td> <input type="text" name="subject" id="subject" value="<?php if(isset($_POST['subject'])) echo $_POST['subject'];?>" class="requiredField subject" size="30" /> <?php if($subjectError != ''){?> <span class="error"><?php echo $subjectError;?></span> <?php }?> </td> </tr> <tr> <th><?php echo __('Message','tstranslate');?></th> <td> <textarea name="comments" id="commentsText" rows="10" cols="80" class="requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea> <?php if($commentError != '') {?> <span class="error"><?php echo $commentError;?></span> <?php }?> </td> </tr> <tr> <th>Captcha</th> <td> <label for="captcha"><?php __('Enter the characters as seen on the image below:','tstranslate');?></label> <div id="captchaimage"> <img src="<?php echo get_template_directory_uri(); ?>/captcha/images/image.php?<?php echo time(); ?>" width="132" height="46" alt="Captcha image" /> </div> <input type="text" maxlength="6" name="captcha" id="captcha" /> <?php if($captchaError != '') {?> <span class="error"><?php echo $captchaError;?></span> <?php }?> </td> </tr> <tr class="field_span"> <td></td> <td> <label for="checking" class="screen"><?php echo __('If you want to submit this form, do not enter anything in this field','tstranslate');?></label> <div class="clear"></div> <input type="text" name="checking" id="checking" class="screenReader" value="<?php if(isset($_POST['checking'])) echo $_POST['checking'];?>" /> </td> </tr> <tr class="btns-send"> <th></th> <td> <input type="hidden" name="submitted" id="submitted" value="true" /> <input type="submit" name="submit" id="submit" class="sended" value="<?php echo __('Send','tstranslate');?>"/> </td> </tr> </table> </form> <?php endwhile; endif; }?> </div><!-- end contact form --> </div><!-- content --> </div><!-- end wrapper content --> <?php get_footer();?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Help making Captcha non case sensitive’ is closed to new replies.