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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:42:43+00:00 2026-05-24T00:42:43+00:00

Below is the code for a member to login and connect to database. I

  • 0

Below is the code for a member to login and connect to database. I have set up the database, the database owner user and password, the database “members” table, and a database member user. The first bit of code is just the html form to log in [it is the index file], the second is the PHP file [checklogin.php] that is supposed to connect said user to the database. The problem is that whatever is typed into html form will let the user to the next page saying “hey, user, you are signed in” even if that user is not in the members table. I have a feeling they are not REALLY connecting at all, it’s just echoing that out. – All db info is keyed out with ++++++

    <html>
    <form action='checklogin.php' method='POST'
    <strong>username:</strong><br />
    <input name="myusername" type="text" id="myusername"><br />
    <strong>password:</strong><br />
    <input name="mypassword" type="password" id="mypassword"><br />
    <input type="submit" name="Submit" value="Login">
    </form>
    </html> 

    <?php
    $host="localhost"; 
    $username="++++++"; 
    $password="++++++"; 
    $db_name="++++++"; 
    $tbl_name="members"; 

    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    $myusername=$_POST['myusername'];
    $mypassword=$_POST['mypassword'];
    echo "hey, " . $myusername . ", you are correctly signed in."
    ?>

Thank you. I am going to add elements of security after I get this going. It is going to eventually log the user in and have have them go right to their profile.

  • 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-24T00:42:44+00:00Added an answer on May 24, 2026 at 12:42 am

    mysql_connect() returns a connection resource that you need to pass to a call to mysql_query(), along with a SQL query to determine if the credentials match a user in the database.

    $con = mysql_connect($server, $dbuser, $dbpass);
    mysql_select_db($db_name)
    

    Your query needs to check the DB to see if $myusername exists, and that the password for $myusername equals $mypassword. You mentioned the table name was members.

    $user = mysql_query("select password from members where username = '" . 
        mysql_real_escape_string($_POST['myusername']) . "'", $con);
    
    if(mysql_num_rows($user) == 0) {
        // Username not found
    }
    
    $user = mysql_fetch_assoc($user);
    if($_POST['password'] != $user['password']) {
        // Password does not match
    }
    

    The actual query depends on the schema of your database.

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

Sidebar

Related Questions

The below code is very simple. I have a jQuery autocomplete bound to an
The below code seems like it should work; however, the blob in the database
I have the below code in stdafx.h. using namespace std; typedef struct { DWORD
What's wrong with this set of code? I have errors and I can't find
First of all, I have to thank StackOverflow and all its members for the
I am trying to specialize some utility code on const member functions, but have
Building my code (below) returns error 'imread' is not a member of 'cv' .
I am new to the usage of iterators. I have used the below code,
I have a simple 'Service' system set up with an interface as shown below.
the code below will calls a member function of the Sales_item object named item1.

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.