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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:49:19+00:00 2026-06-15T16:49:19+00:00

PLEASE dont comment on here telling me about my SQL injections, I already know

  • 0

PLEASE dont comment on here telling me about my SQL injections, I already know :)…

Every time I use my login.html page (which is linked to the login.php file) the code generates the following message: ‘Please enter a valid username and a password!’
The code was working fine earlier so i’m not sure what i have done wrong …

The code is below :

<?php
$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)
{
    $connect = mysql_connect("localhost","user_ben","password") or die ("Couldn't Connect!");
    mysql_select_db("user_phplogin"); //select database

    $query = mysql_query("SELECT * FROM users WHERE username='$username'");
    if(mysql_num_rows($query))
    {
        while ($row = mysql_fetch_assoc($query))
        {
            $dbusername = $row['username'];
            $dbpassword = $row['password'];
        }
        // check to see if they match

        if ($username==$dbusername&&$password==$dbpassword)
        {
            echo "Youre in! <a href='members.php'> Visit your user profile! </a>";
        }
        else
        {
            echo "Incorrect Password! <a href='login.html'> Return to login page</a>";
        }
    }
    else
    {
        die("That user doesnt exist! <a href='login.html'> Return to login page</a>");
    }
}
else
{
    die("Please enter a valid username and a password! <a href='login.html'> Return to login page</a>");
}

?>

This is my form code…

<form action='login.php' method='submit'>
    Username: <input type='text' name='username'/><br>
    Password: <input type='password' name='password'/><br>
    <input type='submit' value='Log In'/>
</form>
  • 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-15T16:49:21+00:00Added an answer on June 15, 2026 at 4:49 pm

    check like

    if(!empty($username) && !empty($password))
    

    it will check not empty also username and password is set

    and

    <form action='login.php' method='POST'>
    

    since it default is GET (it mean if you dont type method it will be GET)

    also you are using method="submit" there isn’t any submit method

    method      (GET|POST)     GET       -- HTTP method used to submit the form--
    

    w3 form:17.3 The FORM element

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

Sidebar

Related Questions

Please, help me. I dont know what is wrong with this code: import android.appwidget.AppWidgetProvider;
Please don't confuse with the title as it was already asked by someone but
EDIT Oct 2016 : Please note this question was asked in 2012. Every month
Note to other potential contributors: Please don't hesitate to use abstract or mathematical notations
please have a look at this code here. class Vehicle { public void printSound()
I don't know why this is happening. I have this code here . It
I am trying to execute a sample application from here: http://www.ixtendo.com/secure-your-jsf-application-with-jaas/#comment-3792 . The author
EDIT: after discussing here click here i decided to use Francis Avila solution, it
I'm new with Symfony2 and with composer.phar to install bundles. Every time I want
I read this comment here: Passing a String by Reference in Java? Yes, it's

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.