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

I want to create form captcha using php and java script

Comments

  • 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>
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!