I'm trying to port a simple logon script that was originally for MySQL to SQLite3. Everything seems to work but won't post data to the database and won't return the else statements if no data is entered or "user added" when submitted.

New and trying to learn PDO with SQLite3...

Can someone give me an idea what's wrong with my code?

The code is below...

--
C Lindgren


CODE <<<<

try {
    /*** connect to SQLite database ***/
    $db = new PDO("sqlite:///my_path/to_my/sqlite3_db_file");
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
    }

if (isset ($_post ['submit'] )) {
        $username = ($_post ['username']);
        $password = ($_post ['password']);
                if (!empty ($username) && !empty ($password)) {
                        $sql=$db->exec("INSERT INTO users(ID,username,password)
                                                        VALUES 
('0','".$username."','".$password."')");
        print 'User Added';
}
        else {
                print 'You must enter a valid Username and Password';
        }
}
        else {

        print '<form action="add_user.php" method="post">
                Username: <input type="text" name="username" /> <br />
                Password: <input type="test" name="password" /> <br />
                <input type="submit" name="submit" value="Add User" />
</form>';
}
?>

CODE<<<<

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to