gpt4 book ai didi

php - 拒绝用户 '' @'localhost' 访问数据库 'finalproject'

转载 作者:行者123 更新时间:2023-12-01 00:12:48 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
PHP - MySQL access denied error - Works in other programs

我正在尝试创建一个连接我的 AdminLogin2.php 和我的 phpmyadmin 中的 admin2 表的登录过程,但它说访问被拒绝。我不知道我该怎么做才能解决它..希望有人能在这里帮助我。这是我的代码,谢谢。

`<?php

$host="localhost";
$username="root";
$password="";
$database="finalproject";
$table="admin2";

$AdminID=$_POST['Field1'];
$Password=$_POST['Field3'];

mysql_connect("$host","$password") or die (mysql_error());
#echo"connected";
mysql_select_db("$database") or die (mysql_error());
#echo"database found";

// To protect MySQL injection (more detail about MySQL injection)
$AdminID = stripslashes($AdminID);
$Password = stripslashes($Password);
$AdminID = mysql_real_escape_string($AdminID);
$Password = mysql_real_escape_string($Password);
$sql="SELECT * FROM $admin2 WHERE username='$AdminID' and password='$Password'";
$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:AdminForm.php");
}
else {
echo "Wrong Username or Password";
}
?>

`

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com