Home Forums PHP How to create form captcha validation using PHP and Java Script ?

Viewing 1 reply thread
  • Author
    Posts
    • #131
      softechquery
      Keymaster

      I want to create form captcha using php and java script

    • #132
      softechquery
      Keymaster

      Use this code

      <?php
      $code=rand(1000,9999);
      ?>
      
      <script>
          function myfun(){ 
              var x = document.getElementById('captcha1').value;
              var y = <?php echo $code  ?>;
      
              if (x == y) {
                  return true;
              }
              else{
                  return false;
              }
          }
      <script>
      <form>
      <span-><?php echo $code;?></span>
      <input id="captcha1" name="captcha" type="text">
      <input id="button" type='submit'  onclick=" return myfun();" value='Submit'>
      </form>
Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Scroll to Top