Authentication help
try to test the PHP code but i keep getting error message can some one help me please dont know what im doing wrong.
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Webroot\checklogin.php on line 10
cannot connect
this is what the code looks like : checklogin.php
<?php
ob_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // 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['mypassword'];
$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("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
loginsuccess.php
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
Login Successful
mainlog.html
Member Login
Username
:
Password
:
Busy posted this at 10:12 — 29th June 2006.
He has: 6,151 posts
Joined: May 2001
usually to run PHP scripts on your PC you run it via http://localhost/Webroot/checklogin.php
try use root as username and leave password blank, host is also usually localhost not the actual hosts name
benzspida posted this at 00:20 — 30th June 2006.
They have: 9 posts
Joined: Jun 2006
thanks
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.