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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:58:25+00:00 2026-05-26T03:58:25+00:00

so my studies have led me to this little problem. (ive been into php

  • 0

so my studies have led me to this little problem. (ive been into php for a solid month so i apologize if im not entirely clear)

i have a small form consisting of user name and pass.

    <form method="post" action="proc.php">
      <table>
        <tr>
            <td>Username:</td>
            <td><input type="text" name="user" id="user"></td>
        </tr>
        <tr>
            <td>password:</td>
            <td><input type="text" name="password" id="password"></td>
        </tr>
            <tr>
            <td></td>
            <td><input type="submit" value="submit"></td>

        </tr>

</table>
</form>

and i have the corresponding values in the db columns.

what im trying to do is, im trying to check the entered name in the form fields against the desired values of the databases columns.

so when i do this to test for just one value in the db(the first value sine its not looping), it works and lets me in:

$dbq = "SELECT * FROM accounts;";
    $dbqDoIt = mysqli_query($connect2db, $dbq)or die("error".mysqli_error($connect2db));

    $getNames = mysqli_fetch_array($dbqDoIt);


    //check if user acc. exists inside vSpot database.
    if(($name !== $getNames['username']) || ($pass !== $getNames['password'])){
        header("Location:index.php"); /* Redirect browser */

for testing my while loop…(cause im new lol), when i do this:

$nums = array(1,2,3,4,5);

for($i=0; $i<6; $i++){
    if($nums[0] < 6 ) echo $i . '<br/>';
}

it works and lists numbers 1-5.

now when i try to loop through db for names/pass, it doesnt work.
like so:

while($getNames = mysqli_fetch_array($dbqDoIt)){
    //check if user acc. exists inside my  database.
    if(($name !== $getNames['username']) || ($pass !== $getNames['password'])){
        header("Location:index.php"); /* Redirect them to log in */

        }

    } 

any ideas as to why its not checking against all the values? im sure im missing something lol.

any tips, advice etc ill gladly appreciate.
thank you in advace

somdow.

  • 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-05-26T03:58:25+00:00Added an answer on May 26, 2026 at 3:58 am

    You don’t need to (AND YOU SHOULDN’T) get all the data from your database table and iterate over all the results just to make this kind of check. Why?

    • This is slow and resource consuming
    • It’s not very secure
    • The database engines are much better to search things in the database (they are made to this kind of task)
    • In large databases you will probably fill all your allowed memory for PHP script execution (this will return errors).

    Try a more specific SQL and use your database engine capabilities for your own good, like so:

    $query = "SELECT user_id FROM accounts WHERE username = :username";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Weird “406 not acceptable” error I've been stuck on this ALL DAY!
Have their been any studies related to the importance of how good a software
I just begin my JPA 2.0 studies, and I have this piece of code:
I have heard there has been some studies of the apple app store for
Have there been any studies comparing OpenCL to OpenMP performance? Specifically I am interested
A friend who studies pure mathematics ask me to think about the following problem.
I haven't worked with SQL Reporting much, however I have been trying to get
I'm using Rails 2. I have resources nested like this: - university_categories - universities
this is the use case I'm trying to figure this out for. I have
I have been working on some of the projects of my own and dont

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.