Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if(isset($_POST['submit']))
{
session_start();
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$query = mysql_query("SELECT * FROM user where username=$username and
password=$password");
$row = mysql_fetch_array($query);
if($row['username']==$username && $row['password']==$password)
{
echo "wellcomo";
}else{
echo "enter correct details";
}
}

What I have tried:

can any one sugget me solution for this
Posted
Updated 21-Jul-18 7:06am
Comments
Richard Deeming 23-Jul-18 13:28pm    
NEVER store passwords in plain text!
Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]

PHP even has built-in functions to help you do the right thing:
PHP: password_hash[^]
PHP: password_verify[^]

Yet another question on this often asked subject.

If you tried a Google search you would find the answer quite quickly. You could find it even quicker by reading the documentation, where it explains the different result types that a MySQL command may return. Hint: do not assume that your command will always succeed.
 
Share this answer
 
PHP
$query = mysql_query("SELECT * FROM user where username=$username and
password=$password");

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900