Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:18+00:00 2026-06-09T12:34:18+00:00

I am trying to make a simple captcha in PHP just for learning purpose,

  • 0

I am trying to make a simple captcha in PHP just for learning purpose, not converting the string into image as of now, I can’t figure what I am doing wrong? I am not even able to verify the code, it’s giving string didn’t match every time

Here’s the code

    <?php


    $var = 'abcdefghijklmnopqrstuywxyz1234567890';

    $random = str_shuffle($var);

    $captcha = substr($random,0,10);
    echo $captcha;


    if(isset($_POST['captcha'])){

    $check = $_POST['captcha'];
    if ($captcha==$check){
    echo 'Verified.';

    }else{echo 'string didn\'t match';}

    }

    ?>
    <form action="random.php" method="POST">
    <input type="text" name="captcha"><br>
    <input type="submit" value="Submit">
    </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:34:19+00:00Added an answer on June 9, 2026 at 12:34 pm

    I don’t recommend this to use for captcha.

    But i am correcting your code only for your learning purpose.

    <?php
    
    session_start();
    
    if(isset($_POST['captcha'])){
    
    $check = $_POST['captcha'];
    if ($_SESSION['captcha']==$check){
    echo 'Verified.';
    
    }else{echo 'string didn\'t match';}
    
    }
    
    $var = 'abcdefghijklmnopqrstuywxyz1234567890';
    
    $random = str_shuffle($var);
    
    $captcha = substr($random,0,10);
    echo $captcha;
    $_SESSION['captcha'] = $captcha;
    
    ?>
    <form action="random.php" method="POST">
    <input type="text" name="captcha"><br>
    <input type="submit" value="Submit">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

excuse me, i'm trying to make simple application which converting the words into word.
Im trying to make a simple app (just for learning sake) that will be
I am trying to make simple notepad application for learning android development. So, to
Trying to make a simple toggle menu, and I can't seem to hide/show the
Trying to make this simple applet - the first part just creates a simple
I'm trying to make simple image gallery with html/css and a bit of javascript.It's
I am trying to make simple app that allows one to compare image to
I am trying to make a simple AJAX calling in PHP and have a
I trying to make a simple image gallery, where I have several radio button
Im trying to make a simple 2D application, and our image processing professor has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.