php - Jquery - execute script & get results if captch correct -


i busy project ip address entered form, ip validated, on fly captch image generated & checked if correct. (the file contains index.php)

only if captcha entered correct run bash script (which being executed query.php).

what struggling returning result bash script query.php div tag on index.php using jquery.

sorry not great explanation still new jquery/javascript.

index.php

    <?php         # check bots         require_once('bot_check.php');         if(is_bot()) {             print "no bots allowed";             exit;         };         session_start();     ?>      <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">     <html xmlns="http://www.w3.org/1999/xhtml">     <head>         <meta http-equiv="content-type" content="text/html; charset=utf-8" />         <title>ip query</title>         <script type="text/javascript" src="jquery-1.2.6.min.js"></script>         <script>             $(document).ready(function() {                   $('#send').click(function() {                     // ip address validation                     var ipaddressval = $("#ipaddr").val();                     var ipreg = /^(([\d]{1,3}\.){3}([\d]{1,3}))?$/;                     if(ipaddressval == '') {                         $("#ipaddr_error").html('');                         $("#ipaddr").after('<label class="error" id="ipaddr_error">please enter ip address.</label>');                         return false                     }                     else if(!ipreg.test(ipaddressval)) {                         $("#ipaddr_error").html('');                         $("#ipaddr").after('<label class="error" id="ipaddr_error">enter valid ip address.</label>');                         return false                     }                     else {                         $("#ipaddr_error").html('');                     }                      $.post("post.php?"+$("#myform").serialize(), {                     }, function(response){                         if(response==1) {                             $("#after_submit").html('');                             $("#send").after('<label class="success" id="after_submit">your message has been submitted.</label>');                             change_captcha();                             clear_form();                             ### part im struggling ####                             if(ipreg.test(ipaddressval)) {                                 $("#send").submit(function() {                                     $.post($(this).attr("query.php?address=1.1.1.1"), $(this).serialize(), function(data) {                                         $("#created").html(data);                                     });                                     return false; // prevent normal submit                                 });                             }                             ### part im struggling ####                         }                         else {                             $("#after_submit").html('');                             $("#send").after('<label class="error" id="after_submit">error ! invalid captcha code .</label>');                             change_captcha();                         }                     });                     return false;                 });                  // refresh captcha                 $('img#refresh').click(function() {                     change_captcha();                 });                  function change_captcha() {                     document.getelementbyid('captcha').src="get_captcha.php?rnd=" + math.random();                 }                  function clear_form() {                     $("#ipaddr").val('');                 }             });         </script>     </head>      <body>         <div style="font-size:30px;">ip query</div>         <br />          <div align="left" style="padding:30px;">             <form action="#" name="myform" id="myform">                 <label>ip address</label>                 <input name="ipaddr" size="30" type="text" id="ipaddr">                 <br />                  <div id="wrap" align="center">                     <img src="get_captcha.php" alt="" id="captcha" />                     <br />                     <input name="code" type="text" id="code">                 </div>                 <img src="refresh.jpg" width="25" alt="" id="refresh" />                 <br /><br />                 <label>&nbsp;</label>                 <input value="query" type="submit" id="send">             </form>         </div>         <div id="created" name="created"></div>          <br /><br /><br /><br />         <br /><br /><br /><br />     </body>     </html> 

post.php

    <?php         session_start();          if(strtolower($_request['code']) == strtolower($_session['random_number'])) {             echo 1; // submitted         }         else {             echo 0; // invalid code         };     ?> 

query.php sends ip & user agent, server address etc bash script, bash script return random amount of lines depending on ip.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -