Jump to content

Login php problem


KeemW

Recommended Posts

Hi, below is the error and php that i used for my login page.

 

Error:

 

 

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 11

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 11

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 12

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 12

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 13

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 13

 

 

Php:

<?php
//session_start(); 
$today = date(Ymd);

$_SESSION[username] = $_POST['username'];
$_SESSION[password] = $_POST['password'];
$_SESSION[id] = $_POST['id'];

$username = stripslashes($_SESSION[username]);
$password = stripslashes($_SESSION[password]);
$username = mysql_real_escape_string($_SESSION[username]);
$password = mysql_real_escape_string($_SESSION[password]);
$id = mysql_real_escape_string($_SESSION[id]);



include('connection.php');
$sql_login = "SELECT id FROM admin WHERE username = '$username' and password = '$password'";
$result_login = mysql_query($sql_login);
$count_login = mysql_num_rows($result_login);
//$row = mysql_fetch_assoc($sql_login);

if($count_login == 1)
{
	
	//session_register("user_email");
	//session_register("user_password");
	//echo "PASS";
	header("location:../admin/main_admin.php");
}
else
{
	header("location:admin_login2.php");
	
}
exit;
?>

Please guide me. 

Link to comment
https://forums.phpfreaks.com/topic/290696-login-php-problem/
Share on other sites

The calls to mysql_real_escape_string() need to be made after the database connection has been established. Try moving them after the following line:

include('connection.php');

Side note: in case you're not aware, the mysql_* function have been deprecated and will be removed in a future version of PHP. If you haven't done so already, you'll need to look into the alternatives at some point:

http://php.net/manual/en/mysqlinfo.api.choosing.php

Link to comment
https://forums.phpfreaks.com/topic/290696-login-php-problem/#findComment-1489132
Share on other sites

I have another problem that i can't solve.

 

Error:

 

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\admin_dashboard.php on line 19

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\admin_dashboard.php on line 19

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Sportify\admin\admin_dashboard.php on line 20

 

 

Php:

<?php
	$id = $_GET['id'];
	$result1 = mysql_query("SELECT * FROM admin WHERE username = '$_SESSION[username]' ORDER BY id");
	while ($row1 = mysql_fetch_assoc($result1))
	{
		$name = mysql_result($result1, 0, 'name');
		$phone = mysql_result($result1, 0, 'phone');
		$email = mysql_result($result1, 0, 'email');
		$address = mysql_result($result1, 0, 'address');
	}
	
	echo "Welcome to Admins Dashboard";

	echo "<div style = 'border:0px solid #000;padding:20px;border-radius:15px;'><table width = '30%'>
			<tr><td colspan =3 style = 'text-align:right;'><a href = 'main_admin.php?page=admin_edit_profile.php&id=$id'><img src = '../images/edit.png' title = 'edit profile' style = 'width:25px;height:25px;'></a>
			<a href = 'main_admin.php?page=admin_edit_password.php&id=$id'><img src = '../images/changepassword.png' title = 'change password' style = 'width:25px;height:25px;'></a>
			</td></tr>
		  	<tr><td>Name</td><td> : </td><td>$name</td></tr></p>";

	echo "<tr><td>Contact</td><td> : </td><td>$phone</td></tr>";

	echo "<tr><td>E-Mail Address</td><td> :</td><td> $email</td></tr>";

	echo "<tr><td>Address</td><td> :</td><td> $address</td></tr></table></div>";

	
	

?>
Link to comment
https://forums.phpfreaks.com/topic/290696-login-php-problem/#findComment-1489136
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.