help with php login script
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();
?>
Busy posted this at 23:01 — 5th July 2006.
He has: 6,151 posts
Joined: May 2001
try change username to root and leave password blank, or just username as root
CptAwesome posted this at 12:44 — 6th July 2006.
He has: 370 posts
Joined: Dec 2004
Well, just plain ol' find out what your MySQL u/p is.
benzspida posted this at 20:02 — 6th July 2006.
They have: 9 posts
Joined: Jun 2006
thank for the help
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.