I am getting following error:
"Access denied for user 'root'@'localhost' (using password: NO)?" Unable to authenticate php/Mysql
I am getting this error using lamp server on ubuntu.
<?php
$not_login = 0;
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$servername = "localhost";
$username = "root";
$password = "";
$con = mysql_connect($servername,$username);
if ($con) {
$db = mysql_select_db("ccmsdb",$con);
}
else{die(mysql_error());
}
$login = "LOGIN";
$userid=$_POST['userid'];
$password = $_POST['password'];
//$password = md5($password);
if ($db) {
$query = "SELECT * FROM client WHERE `userid`='$userid' AND `password`='$password' ";
$result = mysql_query($query);
$rows_count = mysql_num_rows($result);
if ($rows_count>0) {
header("Location:../welcome.php");
}
else
{
$not_login=1;
}
if(!empty($data))
{
}
}
}
?>
<html>
<form action=" " method="post">
<h1>Log-In</h1>
<p> <label for="Userid">User Id:</label>
<input type="text" name="userid">
</p>
<p>
<label for="Password">Password:</label>
<input type="Password" name="password">
</p>
<button>Login</button>
</form>
Aucun commentaire:
Enregistrer un commentaire