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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:20:02+00:00 2026-05-22T22:20:02+00:00

I googled a short tutorial to connect a database and then I wanted to

  • 0

I googled a short tutorial to connect a database and then I wanted to compare the username and password to then can gain access. It is kind of novice coding, but at least I can practice and hopefully pick up programming more.

check.php

<?php
    //Need session//

    $username = 'root';
    $password = 'root';
    $host = 'localhost';
    $db_name = 'pcart';

    $connection = mysql_connect($host, $username, $password) or die('cannot be connected');

    mysql_select_db($db_name, $connection) or die ('Could not select database');
    $user=$_POST['username'];
    $pass=$_POST['password'];

    $query = "Select username, password from tbladmins";
    $user_result = mysql_query($query);
    echo $user_result;
    if (mysql_num_rows($user_result)==0)
    {
        echo "no rows to print";
    }
    while ($row=mysql_fetch_array($user_result, MYSQL_ASSOC))
    {
        $checkuser=$row["username"];
        $checkpass=$row["password"];
    }
    mysql_free_result($user_result);

    if !($user == $checkuser and $pass == $checkpass)
    {
        echo'where are you';
        $results= mysql_query("Select * from tbladmins;") or die('error connecting to mysql');
        if(mysql_num_rows($results)==0)
        {
             echo "no rows found, nothing to print so i am exiting";
        }
        print "test successful"
        mysql_free_result($results);
    }
    else
    {
        echo "Wrong user or password! If you forgot, email Josephine for the username
        and password";
    }
?>

index.php

<html>
    <head>
        <title>Partner Portal
        </title>
    </head>
    <body id="partners-page">
        <div id="main">
            <form method="post" action="Check.php">
                <input type="text" name="username" value=""/>
                <input type="password" name="password" value=""/>
                <input type="submit" name="submit" value="submit">
                <input type="reset" name="reset" value="reset">
            </form>
            <a href="#">forgotten password</a>

        </div>
        <!--#main-->

        </div><!--div partner-page-->
</html>

EDIT

The problem is that it won’t show anything when I am testing if username and password match the one in database… So did I overlook anything? Why was the page blank when I tested inputting username and password?

  • 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-22T22:20:02+00:00Added an answer on May 22, 2026 at 10:20 pm

    Nice Josephine, that’s a great start! Now I know you have heard of the saying, there are a million ways to skin a cat, and this is no exception. There are really a lot of ways to accomplish the above but as of late, this method of doing it have become a bit, how should I say it, un-secure.

    Database connection and user management and implementing it all in a secure way is now contained in every PHP framework you can find. This is all done for you so basically what you have to do is fill in the configuration file and you are good to go.

    Saying that, it’s great to learn how it all ties together and you are on the right track. 😀

    A framework is there to re-use code that you use in every application, and being a software engineer, we re-use a lot, so you do not want to go and duplicate it all over the place.

    Another thing is that the code like this, stays hidden so for instance, I, can’t muck it up and I know it’s tested properly.

    Keep up the good work 😀 It gets a lot more interesting the deeper you go down the rabbit hole.

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

Sidebar

Related Questions

Googled everything, but can't find solution for my problem. When i'm trying to deploy
I googled for this for a while but can't seem to find it and
I googled for Drawing text on picturebox C# ,but I couldnt find anything useful.Then
I'm trying to save an object, I googled the HowTo and got a tutorial
I followed the tutorial exactly: http://github.com/binarylogic/authlogic_example But I am wondering how can I get
I've googled around, but i can find a way to build json with jQuery
Short Description I am having a number of issues trying to connect a Django
I have one text field where user can write short message (like status on
Googled for this to no avail. Didn't find anything in the API either. I
I googled a lot, and could not find a single open source implementation of

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.