way to have php header open same page but showing a hidden div? -


apologies if has been asked before, working on first site , still learning. trying add captcha contact form taken here http://www.captcha.net/ , using php. @ moment working, code supplied on site work follows:

  <html>     <body> <!-- body tag required or captcha may not show on browsers -->       <!-- html content -->        <form method="post" action="verify.php">         <?php           require_once('recaptchalib.php');           $publickey = "your_public_key"; // got signup page           echo recaptcha_get_html($publickey);         ?>         <input type="submit" />       </form>        <!-- more of html content -->     </body>   </html> 

and verify code on different file (server side) is:

  <?php   require_once('recaptchalib.php');   $privatekey = "your_private_key";   $resp = recaptcha_check_answer ($privatekey,                                 $_server["remote_addr"],                                 $_post["recaptcha_challenge_field"],                                 $_post["recaptcha_response_field"]);    if (!$resp->is_valid) {     // happens when captcha entered incorrectly     die ("the recaptcha wasn't entered correctly. go , try again." .          "(recaptcha said: " . $resp->error . ")");   } else {     // code here handle successful verification   }   ?> 

what wondering if there way have if statement (if captcha wrong) open contact page show hidden div displaying captcha code wrong , try again.

in case, can try way:

verify.php

if (!$resp->is_valid) {     header("location: contact.php?show-error"); // replace file name     exit; } else {     // code here handle successful verification } 

contact.php

if(isset($_get['show-error'])){     echo "<div>         recaptcha wasn't entered correctly.          go , try again.     </div>"; } 

or:

<div style="display:<?php echo isset($_get['show-error']) ? "block" : "none"; ?>">     recaptcha wasn't entered correctly.      go , try again. </div> 

but in case, think it's better move verify code contact page. can easy decide show message depend on if condition.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -