创建使用PHP和SQLite简单的登录功能

问题描述 投票:0回答:1

我想创建简单的登录功能,其中我使用PHP和SQLite,使其工作,但每次我点击登录我碰到一个“致命错误:未捕获的异常‘PDOException’有消息在G‘找不到驱动程序’ :\ wwwroot的\的login.php:3堆栈跟踪:#0 G:\ wwwroot的\ login.php中(3):PDO - > __构建体( '源码:G:/ wwwro ...')#1 {主}抛出G:\ wwwroot的\ login.php中第3" 行我做错了什么任何意见将是巨大的:)。

我有登录代码并将其保存为的index.php

<html>
    <body>
        <form action="login.php" method="POST">
        <p>Username</p><input type ="text" name="user"/>
        <p>password</p><input type="password" name="pass"/>
        <br />
        <input type="submit" value="login"/>
        </form>
    </body>
</html>

我有一个名为的login.php另一个PHP和当用户点击登录按钮将被激活

<?php
    $dir = 'sqlite:G:/wwwroot/SQLite/user_information.db';
    $dbh = new PDO($dir) or die ("cannot open");

    $myusername = $_POST['user'];
    $mypassword = $_POST['pass'];

    $myusername = stripslashes($myusername);
    $mypassword = stripslashes ($mypassword);

    $query = "SELECT * FROM user_information WHERE username='$myusername' AND password='$mypassword'";
    $result = mysql_query($query);
    $count = mysql_num_rows($result);

    if($count==1){
    echo'worked';
    }

?>

而在过去的我已经user_information.db这里我下载sqlite3的使用CMD程序来创建数据库。

G:\wwwroot\SQLite>sqlite3 user_information.db
SQLite version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for usage hints.
sqlite> create table user_info(username varchar(20), password varchar(20));
sqlite> insert into user_info values('WESTKINz','password');
sqlite> insert into user_info values('LAME','123456');
php login sqlite cmd
1个回答
0
投票

像错误说,看来你的服务器没有/安装的驱动程序加载。

检查phpinfo,看看是否有驱动程序注册。确保SQLite的扩展在php.ini注释。在Windows中php.ini文件可能会在C:\Windows\System32\PHP\php.ini。 phpinfo()函数应该告诉你,哪里的配置所在。见this岗位。

此外,类似的职位与MySQL

© www.soinside.com 2019 - 2024. All rights reserved.