Trying to create an authentication and tracking script . but when ever I run the script I keep getting an error message(
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'john'@'localhost' (using password: YES) in C:\Webroot\Authen1\checklogin.php on line 10
cannot connect
here is my code
<?php
ob_start();
$host="localhost"; // Host name
$username="john"; // Mysql username
$password="1234"; // Mysql password
$db_name="dbUsername"; // Database name
$tbl_name="Authenticate"; // Table name
// Connect to server and select databse.
mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db($db_name)or die("cannot select DB");
// Define $myusername and $mypassword
$myusername=$POST['myusername'];
$mypassword=$POST['myusername'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("myusername");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>