I have basic login system in php . the form on index page submits username and password to same page using POST
method .The username and password are hard coded .
Here is php code on index page that handles
if( isset ($_POST['submit']) ) {
$username='Admin';
$password='root';
if( ( $_POST['uname'] == $username ) && ( $_POST['pass'] == $password) ) {
// Redirect to admin page
}
else{
echo "Wrong credential";
}
}
I have referred to This question but unable to understand why hard coding is bad in these case .
my arguments
- This eliminates sql injection possibility
- Source code will never been seen if error reporting is off.
Since you are not using database this doesn't eliminates sql injection possibility. You should store username and password in database, store these thought some hashing algorithm for example SHA1, and apply "golden rule filter inputs and escape outputs".