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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:37:18+00:00 2026-06-07T14:37:18+00:00

I am trying to set up a user login page (basic training as i

  • 0

I am trying to set up a user login page (basic training as i learn php) but the page is not working as i think i have problems with the part where i count the number of rows (i check that the number of rows in my user_table database where the login and password inputed match to tthe one that have been entered is =1).

I’m in PDO and I don’t want to use mysql_num_rows which is being deprecated or at least it is recommended not to use it. Instead, I want to use Found_rows

Here is my login_page.php:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <title>LOGIN PAGE</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Connect to your account</h1>
    <form method="post" action="login_verify.php">
        <input type="text" name="inputed_username" size="35" maxlength="30" required="required" value="Enter your login" /><br/><br/>
        <input type="password" name="inputed_password" size="35" maxlength="30" required="required" value="Enter your password" /><br/><br/>
        <input type="submit" name="submit "value="Connect me !" />         
    </form>
</body>
 </html>

Then here is the php file where I check if the {login,password} entered are correct in this login_verify.php file:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <title>login process check-up</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
    if (isset($_POST['submit']))//if the button submit has not been clicked on
    {
        try
        {
            //database connection          
            $dbhost     = "localhost";
            $dbname     = "test";
            $dbuser     = "root";
            $dbpass     = "";

            $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
            $bdd = new PDO("mysql:host=$dbhost;dbname=$dbname; charset=UTF8",$dbuser,$dbpass,$pdo_options);
            $bdd -> query('SET NAMES utf8'); 

            //the database is checked to see if there is a match for the couple {user,password}

            $user = $_POST['inputed_username'];
            $password = $_POST['inputed_password'];
            //preparaiton and execution of the request
            $req = $bdd->prepare('SELECT * from user_table WHERE login= :login && password= :password LIMIT 1');
            $req->execute(array(
            'login' => $user,
            'password' => $password));
            $foundrows = $req->query("SELECT FOUND_ROWS()")->fetchColumn();//the number of rows are counted

            //we check if there is a match for the login-password
            if ($foundrows == 1)//if we find one that matches
            {
                session_start();
                $_SESSION['username'] = $req['login'];
                $_SESSION['fname'] = $req['first_name'];
                $_SESSION['lname'] = $req['last_name'];
                $_SESSION['logged'] = TRUE;
                header("Location: first_page.php");
                exit();
            }
            else //if we don't find any match
            {
                header("Location: login_page.php");
                exit;
            }
        }
        catch (Exception $e)
        {
            die('Erreur: '.$e->getMessage());
        }

    }
    else //if the submit button has  not been clicked on
    {
        header ("Location: login_page.php");
        exit;
    }
?>

If any of you know where the problem lies it would be great.

I think it comes from a misuse of found_rows. It’s the first time I use it so I feel I’ve something badly but I don’t know what it is.

  • 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-07T14:37:21+00:00Added an answer on June 7, 2026 at 2:37 pm

    FOUND_ROWS() only works if you use it after a select query where you had the SQL_CALC_FOUND_ROWS option in the select query, and is only truly useful if it’s a LIMIT query. FOUND_ROWS() is the number of rows that WOULD have been returned if not for the limit clause.

    SELECT SQL_CALC_FOUND_ROWS ... WHERE ... LIMIT 10
    SELECT FOUND_ROWS()
    

    For non-LIMITed queries, you use mysql_num_rows() instead.

    Presumably your database is setup that login is a primary/unique key field, so your query would only ever return at most one row anyways, so the limit is pointless.

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

Sidebar

Related Questions

Trying to set up the Login control as a User control, but none of
I am trying to set up a page that will allow the user to
I'm trying to set up a simple login using AuthLogic into my User table.
I have been trying to set up facebook on a page via a function
I am trying to set up my robots.txt, but I am not sure about
I'm trying to show a login box in my page only if the user
I created a django application with a user login/registration page. I am trying to
I'm trying to make a login page for my CakePHP website, and my user
I am stuck on a issue. I am trying to set user-environment variables using
I am trying to set my user agent string in the HttpClient apache object

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.