如何将mysql数据库连接到网站

时间:2017-04-12 13:27:20

标签: javascript php css mysql html5

我尝试连接,浏览器没有实现代码,只是显示代码。以下是我的代码。

<?php

    $inputuser = $_POST['user'];
    $inputpass = $_POST['pass'];

    $user = "root";
    $password = "";
    $database = "tutorial";
    $connect = mysql_connect("localhost",$user,$password);
    @mysql_select_db($database) or ("Database not found");

    $query = "SELECT * FROM 'users' where 'user' = '$inputuser'";
    $querypass = "SELECT * FROM 'users' where 'password' = '$inputpass'";

    $result = mysql_query($query);
    $resultpass = mysql_query($querypass);

    $row = mysql_fetch_array($result);
    $rowpass = mysql_fetch_array($resultpass);

    $serveruser = $row["user"];
    $serverpass = $row["password"];

    if($serveruser&&$serverpass){
        if(!$result){
            die("username or password is invalid");
        }
        echo "<br><center><Database output</br></center><br><br>";
        mysql_close();
        echo $username;
        echo $password;

    }
?>

0 个答案:

没有答案