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

  • Home
  • SEARCH
  • 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 7882509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:18:09+00:00 2026-06-03T04:18:09+00:00

I’m having trouble inserting a reCAPTCHA within a log in system, it seems the

  • 0

I’m having trouble inserting a reCAPTCHA within a log in system, it seems the user can enter the correct username and password without even inserting anything within the reCAPTCHA. An example log in user is – username = steven password = steven

Below is the link to the site and the code for the log in page and then the staff area page code.

http://newmedia.leeds.ac.uk/ug10/cs10dw/workspace1/login.php

Anyone help would be greatly appreciated.

<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php


    include_once("includes/form_functions.php");

    // START FORM PROCESSING
    if (isset($_POST['submit'])) { // Form has been submitted.
        $errors = array();

        // perform validations on the form data
        $required_fields = array('username', 'password');
        $errors = array_merge($errors, check_required_fields($required_fields, $_POST));

        $fields_with_lengths = array('username' => 30, 'password' => 30);
        $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));

        $username = trim(mysql_prep($_POST['username']));
        $password = trim(mysql_prep($_POST['password']));
        $hashed_password = sha1($password);

        if ($_POST) { 
        require_once($_SERVER['DOCUMENT_ROOT'] . '/recaptcha/recaptchalib.php');
        $privatekey ="6LcHbc0SAAAAAOs2d7VnzV7RtedMkLs306ekQPUP";
        $resp = recaptcha_check_answer ($privatekey,
                            $_SERVER['REMOTE_ADDR'],
                            $_POST['recaptcha_challenge_field'],
                            $_POST['recaptcha_response_field']);
        $str_result = "";
        if (!$resp->is_valid) {
             // What happens when the CAPTCHA was entered incorrectly
            $message = "The reCAPTCHA wasn't entered correctly. Go back and try it again. (reCAPTCHA   said: " . $resp->error . ")";
            // Add a redirect to an error page or just put an exit(); here

        } 

    }




        if ( empty($errors) ) {
            // Check database to see if username and the hashed password exist there.
            $query = "SELECT * ";
            $query .= "FROM users ";
            $query .= "WHERE username = '{$username}' ";
            $query .= "AND hashed_password = '{$hashed_password}' ";

            $result_set = mysql_query($query);
            confirm_query($result_set);
            if (mysql_num_rows($result_set) == 1) {
                // username/password authenticated
                // and only 1 match
                $found_user = mysql_fetch_array($result_set);
                redirect_to("staff.php");
            } else {
                // username/password combo was not found in the database
                $message = "<h1> Username or password is incorrect. </h1><br />
            ";
            }
        }
    }
?>
<?php include("includes/header.php"); ?>
<table id="structure">
    <tr>
        <td id="navigation">
            <a href="index.php">Return to public site</a>
        </td>
        <td id="page">
            <h2>Staff Login</h2>
            <?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
            <?php if (!empty($errors)) { display_errors($errors); } ?>
            <form action="login.php" method="post">
            <table>
                <tr>
                    <td>Username:</td>
                    <td><input type="text" name="username" maxlength="30" value="<?php echo htmlentities($username); ?>" /></td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><input type="password" name="password" maxlength="30" value="<?php echo htmlentities($password); ?>" /></td>
                </tr>
                <tr>

  <?php
    require_once($_SERVER['DOCUMENT_ROOT'] . '/recaptcha/recaptchalib.php');
    $publickey = "6LcHbc0SAAAAABQAnCHSHGhSuSXkZ2d1MoBa4xw2";
    echo recaptcha_get_html($publickey);
?>

                    <td colspan="2"><input type="submit" name="submit" value="Login" /></td>
                </tr>
            </table>

            </form>
        </td>
    </tr>
</table>
<?php include("includes/footer.php"); ?>

* STAFF PAGE *

<?php require_once("includes/functions.php"); ?>

<?php include("includes/header.php"); ?>
<table id="structure">
    <tr>
        <td id="navigation">&nbsp;

        </td>
        <td id="page">
            <h2>Staff Menu</h2>

            <ul>
                <li><a href="content.php">Manage Website Content</a></li>
                <li><a href="new_user.php">Add Staff User</a></li>
                <li><a href="logout.php">Logout</a></li>
            </ul>
        </td>
    </tr>
</table>
<?php include("includes/footer.php"); ?>
  • 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-03T04:18:10+00:00Added an answer on June 3, 2026 at 4:18 am

    Try this:

        // if ($_POST) {    // Don't need this
    
            require_once($_SERVER['DOCUMENT_ROOT'] . '/recaptcha/recaptchalib.php');
            $privatekey ="6LcHbc0SAAAAAOs2d7VnzV7RtedMkLs306ekQPUP";
            $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER['REMOTE_ADDR'],
                                $_POST['recaptcha_challenge_field'],
                                $_POST['recaptcha_response_field']);
            $str_result = "";
            if (!$resp->is_valid) {
                 // What happens when the CAPTCHA was entered incorrectly
                $message = "The reCAPTCHA wasn't entered correctly. Go back and try it again. (reCAPTCHA   said: " . $resp->error . ")";
                echo $message;
                exit();
    
            } 
    
        //}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.