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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:41:01+00:00 2026-06-10T22:41:01+00:00

ive written a php function that displays a random equation. if the correct answer

  • 0

ive written a php function that displays a random equation. if the correct answer is not provided, the submission fails. the equation is like so:

[ random digit or text number ] [ randomly selects +,-,x ] [ random digit or text number ]= ?

so you might see:
8+2=?, or seven – 4 = ?, etc

ive tested this manually and it seems to work beautifully. i cannot get around answering the CAPTCHA correctly. yet something or someone IS posting spam despite this CAPTCHA. so my question is, are there programs out there that can solve this problem?

here is my form:

<form action="scripts/handler_post.php" method="post" id="gb_form">
                    <h3>Leave us a comment:</h3><br />
                    <div id="form_msg"><?php echo $msg; ?></div>
                    <input type="text" name="name" value="Your Name" />
                    <textarea name="message">Your Message</textarea>

                    <?php include('includes/bmw_captcha.php'); ?> 
                    <div style="color:red; font-size:90%;">*What does <?php echo $array_num1[1] . " " . $array_calculation[0] . " " . $array_num2[1] . " = "; ?>    
                    <input type='text' maxlength='2' name='captcha' style="color:#640513; width:25px;" />?</div>
                    <div><span style="font:italic 90% Arial; color:#666;">(For security purposes, please answer this CAPTCHA problem.)</span></div>
                    <input type="hidden" name="captcha_answer" value="<?php echo $array_calculation[1]; ?>" />

                    <input type="submit" name="submit_button" value="Post" />
                </form>

here is the script that handles the form:

// submitted values
$name       = clean_string( $_POST['name'] );
$message    = clean_string( $_POST['message'] );
$captcha    = clean_string( $_POST['captcha'] );
$captcha_ans= clean_string( $_POST['captcha_answer'] );

// check if name var is empty or contains digits
if( empty($name) || (strcspn( $name, '0123456789' ) != strlen( $name )) ) 
{ header( 'Location: /guestbook.php?msg=n' ); }

else if( empty($message) )
{ header( 'Location: /guestbook.php?msg=m' ); }

else if( empty($captcha) || $captcha != $captcha_ans )
{ header( 'Location: /guestbook.php?msg=cap' ); }

else 
{
    $query = "
            INSERT INTO $table_posts ( id, name, message, timestamp ) 
            VALUES( 0, \"$name\", \"$message\", now() )
    ";

    $result = $db_connect->query( $query ); // execute the query

    if( $result )
    {       
        header('Location: ../guestbook.php?msg=1');
    }

    else
        header('Location: ../guestbook.php?msg=2');
}
  • 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-10T22:41:03+00:00Added an answer on June 10, 2026 at 10:41 pm

    You should store the answer to the captcha in a session variable instead. Sending it in clear text through the form makes it possible for a robot to just set the field to whatever value it wants. Bots are usually setting all unknown fields to some string, like ijhsg87dfb34 so if it sets both the captcha and the captcha_answer field to the same value it will succeed!

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

Sidebar

Related Questions

I've written a js function that asynchronously contacts the server via a php query
I have a php function I've written that sorts player's fastest race times. However,
I've written a PHP function that can accept 10 parameters, but only 2 are
I've written a PHP function to get plus ones count for a URL function
I've written this short piece of php code that requires 2 variables name and
I've written a module that depends on an overridden value in $conf in settings.php.
I've written a PHP script that iterates through a given folder, extracts all the
I've written and played around with alot of PHP function and variables where the
I've written a some PHP that interacts with a SQL database and is just
I've written a PHP script that makes a request to a search engine, accesses

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.