注册错误&用Hostinger登录PHP

时间:2015-10-03 00:59:26

标签: php mysql pdo phpmyadmin forum

所以我一直在与朋友建立一个论坛&当他试图设计时,他挑战了我做了很多服务器端的事情。我收到了很多这些错误的

免责声明:我知道已经发布了很多内容,但我发现它很难理解我。

免责声明:我是中级的​​,所以我没有专业的PHP并且已经在这个小时进行了调试。

这是我的login.php

<?php
//This page let log in
include('config.php');
if(isset($_SESSION['username']))
{
    unset($_SESSION['username'], $_SESSION['userid']);
    setcookie('username', '', time()-100);
    setcookie('password', '', time()-100);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
        <title>Login</title>
    </head>
    <body>
        <div class="header">
            <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Forum" /></a>
        </div>
<div class="message">You have successfully been logged out.<br />
<a href="<?php echo $url_home; ?>">Home</a></div>
<?php
}
else
{
    $ousername = '';
    if(isset($_POST['username'], $_POST['password']))
    {
        if(get_magic_quotes_gpc())
        {
            $ousername = stripslashes($_POST['username']);
            $username = mysql_real_escape_string(stripslashes($_POST['username']));
            $password = stripslashes($_POST['password']);
        }
        else
        {
            $username = mysql_real_escape_string($_POST['username']);
            $password = $_POST['password'];
        }
        $req = mysql_query('select password,id from users where username="'.$username.'"');
        $dn = mysql_fetch_array($req);
        if($dn['password']==sha1($password) and mysql_num_rows($req)>0)
        {
            $form = false;
            $_SESSION['username'] = $_POST['username'];
            $_SESSION['userid'] = $dn['id'];
            if(isset($_POST['memorize']) and $_POST['memorize']=='yes')
            {
                $one_year = time()+(60*60*24*365);
                setcookie('username', $_POST['username'], $one_year);
                setcookie('password', sha1($password), $one_year);
            }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
        <title>Login</title>
    </head>
    <body>
        <div class="header">
            <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Forum" /></a>
        </div>
<div class="message">You have successfully been logged.<br />
<a href="<?php echo $url_home; ?>">Home Page</a></div>
<?php
        }
        else
        {
            $form = true;
            $message = 'The username or password you entered are not good.';
        }
    }
    else
    {
        $form = true;
    }
    if($form)
    {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
        <title>Login</title>
    </head>
    <body>
        <div class="header">
            <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Forum" /></a>
        </div>
<?php
if(isset($message))
{
    echo '<div class="message">'.$message.'</div>';
}
?>
<div class="content">
<?php
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
?>
<div class="box">
    <div class="box_left">
        <a href="<?php echo $url_home; ?>">Forum Index</a> &gt; Login
    </div>
    <div class="box_right">
        <a href="list_pm.php">Your messages(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Logout</a>)
    </div>
    <div class="clean"></div>
</div>
    <form action="login.php" method="post">
        Please, type your IDs to log:<br />
        <div class="login">
            <label for="username">Username</label><input type="text" name="username" id="username" value="<?php echo htmlentities($ousername, ENT_QUOTES, 'UTF-8'); ?>" /><br />
            <label for="password">Password</label><input type="password" name="password" id="password" /><br />
            <label for="memorize">Remember</label><input type="checkbox" name="memorize" id="memorize" value="yes" /><br />
            <input type="submit" value="Login" />
        </div>
    </form>
</div>
<?php
    }
}
?>
        <div class="foot"><a href="http://www.anmolb.esy.es">Developers Site</a> - Developed By LivingLife_</div>
    </body>
</html>

以下是我通过登录页面收到的错误。

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/config.php on line 9

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/config.php on line 9

Deprecated: mysql_select_db(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/config.php on line 10

Warning: mysql_select_db(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/config.php on line 10

Warning: mysql_select_db(): A link to the server could not be established in /home/u134164949/public_html/forum/config.php on line 10

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/login.php on line 38

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/login.php on line 38

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/u134164949/public_html/forum/login.php on line 38

Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/login.php on line 41

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/login.php on line 41

Warning: mysql_query(): A link to the server could not be established in /home/u134164949/public_html/forum/login.php on line 41

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/u134164949/public_html/forum/login.php on line 42
Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/login.php on line 102

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/login.php on line 102

Warning: mysql_query(): A link to the server could not be established in /home/u134164949/public_html/forum/login.php on line 102

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/u134164949/public_html/forum/login.php on line 102

这是signup.php代码

<?php
//This page let users sign up
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
        <title>Sign Up</title>
    </head>
    <body>
        <div class="header">
            <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Espace Membre" /></a>
        </div>
<?php
if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['avatar']) and $_POST['username']!='')
{
    if(get_magic_quotes_gpc())
    {
        $_POST['username'] = stripslashes($_POST['username']);
        $_POST['password'] = stripslashes($_POST['password']);
        $_POST['passverif'] = stripslashes($_POST['passverif']);
        $_POST['email'] = stripslashes($_POST['email']);
        $_POST['avatar'] = stripslashes($_POST['avatar']);
    }
    if($_POST['password']==$_POST['passverif'])
    {
        if(strlen($_POST['password'])>=6)
        {
            if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
            {
                $username = mysql_real_escape_string($_POST['username']);
                $password = mysql_real_escape_string(sha1($_POST['password']));
                $email = mysql_real_escape_string($_POST['email']);
                $avatar = mysql_real_escape_string($_POST['avatar']);
                $dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
                if($dn==0)
                {
                    $dn2 = mysql_num_rows(mysql_query('select id from users'));
                    $id = $dn2+1;
                    if(mysql_query('insert into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")'))
                    {
                        $form = false;
?>
<div class="message">You have successfully been signed up. You can now log in.<br />
<a href="login.php">Log in</a></div>
<?php
                    }
                    else
                    {
                        $form = true;
                        $message = 'An error occurred while signing you up.';
                    }
                }
                else
                {
                    $form = true;
                    $message = 'Another user already use this username.';
                }
            }
            else
            {
                $form = true;
                $message = 'The email you typed is not valid.';
            }
        }
        else
        {
            $form = true;
            $message = 'Your password must have a minimum of 6 characters.';
        }
    }
    else
    {
        $form = true;
        $message = 'The passwords you entered are not identical.';
    }
}
else
{
    $form = true;
}
if($form)
{
    if(isset($message))
    {
        echo '<div class="message">'.$message.'</div>';
    }
?>
<div class="content">
<div class="box">
    <div class="box_left">
        <a href="<?php echo $url_home; ?>">Forum Index</a> &gt; Sign Up
    </div>
    <div class="box_right">
        <a href="signup.php">Sign Up</a> - <a href="login.php">Login</a>
    </div>
    <div class="clean"></div>
</div>
    <form action="signup.php" method="post">
        Please fill this form to sign up:<br />
        <div class="center">
            <label for="username">Username</label><input type="text" name="username" value="<?php if(isset($_POST['username'])){echo htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
            <label for="password">Password<span class="small">(6 characters min.)</span></label><input type="password" name="password" /><br />
            <label for="passverif">Password<span class="small">(verification)</span></label><input type="password" name="passverif" /><br />
            <label for="email">Email</label><input type="text" name="email" value="<?php if(isset($_POST['email'])){echo htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
            <label for="avatar">Avatar<span class="small">(optional)</span></label><input type="text" name="avatar" value="<?php if(isset($_POST['avatar'])){echo htmlentities($_POST['avatar'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
            <input type="submit" value="Sign Up" />
        </div>
    </form>
</div>
<?php
}
?>
        <div class="foot"><a href="http://www.anmolb.esy.es">Developers Site</a> - Developed By LivingLife_</div>
    </body>
</html>

以下是我对此代码的错误

    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/config.php on line 9

        Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/config.php on line 9

        Deprecated: mysql_select_db(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/config.php on line 10

        Warning: mysql_select_db(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/config.php on line 10

        Warning: mysql_select_db(): A link to the server could not be established in /home/u134164949/public_html/forum/config.php on line 10
Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 33

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 33

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 33

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 34

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 34

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 34

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 35

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 35

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 35

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 36

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 36

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 36

Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 37

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 37

Warning: mysql_query(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 37

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u134164949/public_html/forum/signup.php on line 37

Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 40

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 40

Warning: mysql_query(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 40

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u134164949/public_html/forum/signup.php on line 40

Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u134164949/public_html/forum/signup.php on line 42

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory") in /home/u134164949/public_html/forum/signup.php on line 42

Warning: mysql_query(): A link to the server could not be established in /home/u134164949/public_html/forum/signup.php on line 42

感谢您提供任何其他信息,这对我来说是第一次体验:)

1 个答案:

答案 0 :(得分:0)

尝试添加.delay(2, TimeUnit.SECONDS, Schedulers.trampoline()) ...将mysqli_connect的所有实例替换为mysql ..您正在使用程序方法...... mysqli提供了这种方法....

mysqlimysqli的改进版本..不再使用mysql

相关问题