php - 登录后看不到我的网站

标签 php html mysql post

我的网站成员(member)区域的“index.php”中出现错误,我遇到了这些错误

Warning: mysql_connect() [function.mysql-connect]: Host 'srv9.000webhost.com' is not allowed to connect to this MySQL server in /home/a8479867/public_html/pages/index.php on line 6

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/a8479867/public_html/pages/index.php on line 7

Warning: mysql_query() [function.mysql-query]: Access denied for user 'a8479867'@'localhost' (using password: NO) in /home/a8479867/public_html/pages/index.php on line 11

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/a8479867/public_html/pages/index.php on line 11

SQL 错误!

SELECT count(*) FROM membre WHERE login="momo1o4" AND pass_md5="b83287a789719ce4a412b0b9da582cee"
Access denied for user 'a8479867'@'localhost' (using password: NO)

这是我的代码

<?php
// on teste si le visiteur a soumis le formulaire de connexion
if (isset($_POST['connexion']) && $_POST['connexion'] == 'Connexion') {
    if ((isset($_POST['login']) && !empty($_POST['login'])) && (isset($_POST['pass']) && !empty($_POST['pass']))) {

    $base = mysql_connect ('server', 'login', 'password');
    mysql_select_db ('nom_base', $base);

    // it tests whether a database entry contains the couple login / pass
    $sql = 'SELECT count(*) FROM membre WHERE login="'.mysql_escape_string($_POST['login']).'" AND pass_md5="'.mysql_escape_string(md5($_POST['pass'])).'"';
    $req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
    $data = mysql_fetch_array($req);

    mysql_free_result($req);
    mysql_close();

    // if a response is obtained, then the user is a member
    if ($data[0] == 1) {
        session_start();
        $_SESSION['login'] = $_POST['login'];
        header('Location: membre.php');
        exit();
    }
    // if there is no response, the visitor was wrong either in his login or password in
    elseif ($data[0] == 0) {
        $erreur = 'Compte non reconnu.';
    }
    // if not, then there is a big problem :)
    else {
        $erreur = 'Probème dans la base de données : plusieurs membres ont les mêmes identifiants de connexion.';
    }
    }
    else {
    $erreur = 'Au moins un des champs est vide.';
    }
}
?>
<html>
<head>
<title>Accueil</title>
</head>

<body>
Connexion à l'espace membre :<br />
<form action="index.php" method="post">
Login : <input type="text" name="login" value="<?php if (isset($_POST['login'])) echo htmlentities(trim($_POST['login'])); ?>"><br />
Mot de passe : <input type="password" name="pass" value="<?php if (isset($_POST['pass'])) echo htmlentities(trim($_POST['pass'])); ?>"><br />
<input type="submit" name="connexion" value="Connexion">
</form>
<a href="inscription.php">Vous inscrire</a>
<?php
if (isset($erreur)) echo '<br /><br />',$erreur;
?>

</body>
</html>

最佳答案

您似乎正在尝试使用 ftp 用户名 (a8479867) 连接到 mysql,但我很确定您仍然需要手动将该用户(使用正确的密码)添加到 mysql。

您的虚拟主机面板中应该有一个选项来创建 mysql 用户并更新其密码。

关于php - 登录后看不到我的网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22298089/

相关文章:

php - PHP中可以使用私有(private)常量吗?

php - 无法在 PHP 中导入/使用命名空间函数

html - 希望使此菜单响应较小的屏幕和设备

java - 为什么在使用 DriverManager.getConnection 时我的 SQL 连接会卡住?

php - 如何在php中的一页中使用2个数据库连接

php - 中文本地化不适用于 PHP gettext 扩展,因为它适用于英语

php - 调用非对象上的成员函数 userdata()

javascript - 面向学生的基于位置的网络网站

javascript - 在输入字段发生任何变化时调用 jQuery 函数

mysql - 是否应该始终将主键添加到 innodb 表中?