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 9008039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:50:54+00:00 2026-06-16T01:50:54+00:00

I am trying to integrate a captchia code with using a form. What I

  • 0

I am trying to integrate a captchia code with using a form. What I have is a basic format to where I was able to get the captcha part working on its own php page. Also I was able to display a form in its own php page. The problem I am having is I’m not sure how to get both parts working together.

This is a snipit of what I have:

<?php
session_start();
    if (isset($_POST['captcha'])) {
        $_SESSION['captcha'] = rand(0, 99999999999);
        } else {
            if ($_SESSION['captcha']!==$_POST['captcha']) {
            echo 're-enter a new captcha!';
            $_SESSION['captcha'] = rand(0, 99999999999);
        }
    }
?>

    <form action="formx.php" method="POST">
            <ul>
                <li>
                    Username:<br>
                    <input type"text" name="username">
                </li>
                <li>
                    Password:<br>
                    <input type="password" name="password">
                </li>
                <li>
                    Password again:<br>
                    <input type="password" name="password2">
                </li>
                <li>
                    Email:<br>
                    <input type="text" name="email">
                </li>
                <li>
                    <input type="submit" name="captcha" value="submit">
                </li>
            </ul>
    </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-16T01:50:55+00:00Added an answer on June 16, 2026 at 1:50 am

    If you walk through it, you are probably missing a couple steps:

    if ($_SERVER['REQUEST_METHOD']!='POST')  //If initial load, load up captcha into session
        $_SESSION['captcha'] = rand(0,9999999999);
    else{//Means form was submitted
        if (isset($_POST['captcha'])) {//Check if they entered
            if ($_SESSION['captcha']!==$_POST['captcha']) {//check if ! correct, reissue new captcha
                echo 're-enter a new captcha!';
                $_SESSION['captcha'] = rand(0, 99999999999);
            }else{
                //Everything was good, handle data
            }
        }else{//Nothing was entered, give them new captcha
            echo 'please enter the captcha!';
            $_SESSION['captcha'] = rand(0, 99999999999);
        }
    
    }
    

    Now the tricky part comes when you display this to the user. If you put:

    <li>
        Please type <?=$_SESSION['captcha']?>:<br/>
        <input type="submit" name="captcha" value="submit">
    </li>
    

    bots will be able to bypass this. So you need to figure out how to over come this problem. Simply displaying the number and telling them to enter is good and will deter VERY basic bots. Obfuscating it (<span>1</span><span>2</span>) may make it a little more difficult, but bots can still parse it and bypass it. Saving it as a Javascript variable and then checking against it may also work, but again, can be bypassed if the bot is smart enough. An iframe may work, an image may work, user-agent parsing may help, etc etc etc. All these things would work, but it is up to you on how you want to implement it and how secure you want it.

    Personally, while I am a fan of Recaptcha as it is usually very easy to implement and requires minimal coding on my end. I also use the GD and TrueType libraries to make captcha images, but this does require a lot more programming than it may be worth if you can use Recaptcha. Finally, I do like Javascript math problems that are loaded after the page loads, which bots have a harder time loading and figuring out what is going on.

    After all is said and done, do whatever you want. If you get stuck, post your code and we can help you out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate Facebook sharing into a webpage using this code edited from
Trying to integrate my webapp with Twitter using twitter4j lib. I have registered my
Im trying to integrate Brad Larson's GPUImage framework to my project. The sample code
I'm trying to integrate passport into my nodejs server using connect, but can't seem
I'm trying to integrate bean validation using hibernate validator to my web application :
I'm trying to integrate FNV hashing algorithm on a PHP-based project as part of
I am trying to integrate forem with thumbs_up. I have inherited the forem Post
We are trying to integrate the System.Web.Providers membership management into a transaction using System.Transactions.TransactionScope
I am trying to integrate git into my workflow. I'm starting it by using
I am trying to integrate my timesheets app with Fogbugz by using a text

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.