justuptime.com - monitor your servers & websites

help with php login script

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 9 posts

Joined: Jun 2006

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's picture
Modrater

He has: 6,157 posts

Joined: May 2001

try change username to root and leave password blank, or just username as root

CptAwesome's picture
Sponsor

He has: 370 posts

Joined: Dec 2004

Well, just plain ol' find out what your MySQL u/p is.

They have: 9 posts

Joined: Jun 2006

thank for the help