Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

it could be able to detect users that are already added in the database but i can't insert datahaving trouble with my insert code

<?php
$user_id= $_POST['user_id'];
$username = $_POST['username'];
$email = $_POST['email'];
If ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $db = new SQLite3('users.db');
    $stmt = $db->prepare('SELECT * FROM user WHERE
            LOWER(username)=:username');
    // case insensitive usernames
    $stmt->bindValue(':username', strtolower($username));
    $result = $stmt->execute();
    $row = $result->fetchArray();
    If ($row) {
        echo 'Username already exists.';
        exit;
    }
    else {
        $insert = "INSERT INTO user (user_id, username, email) VALUES (Null,:username,:email)";
        $stmp=$users-prepare($insert);
        $stmt->bindParam(':user_id',Null);
        $stmt->bindParam(':username',strtolower($username));
        $stmt->bindParam(':email', $email);
        echo 'Registration successful. Please check your email.';
        exit;

Comments