'Adding a new wordpress user through HTML form

I want to add a new WordPress user to the table wp_users through HTML form but for some reason, it just doesn't work. What could be wrong? Do I need to insert other inputs? Or maybe to create a different table for this?

This is my HTML code:

 <span class="bottomForm">
            <p style="color:red; font-weight: bold;">
                < חזרה לעגלת הקניות </p> <button class="bottomButton" type="button" onclick="submitForm()"
                    name="save_contact">המשך
                    לאפשרויות משלוח</button>
        </span>

    </form>
    <script type="text/javascript">
        function submitForm() {
            var email = $('input[name=user_email]').val();
            var password = $('input[name=user_pass]').val();
            var formData = {
                email: user_email,
                password: user_pass
            };
            $.ajax({
                url: "http://localhost/quatro/api/submit.php",
                type: 'POST',
                data: formData,
                success: function (response) {

                }
            })

        }
    </script>

My PHP code:

$host = "localhost";
$username = "root";
$password = "";

try {
    $conn = new PDO("mysql:host=$host;dbname=quatro", $user_email, $user_pass);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}

$response = array('success' => false);

if (isset($_POST['user_email']) && $_POST['user_email'] != '' && isset($_POST['user_pass']) && $_POST['user_pass'] != '') {
    $sql = "INSERT INTO wp_users(user_email user_pass,) VALUES('" . addslashes($_POST['user_email']) . "', '" . addslashes($_POST['user_pass']) . "')";

    if ($conn->query($sql)) {
        $response['success'] = true;
    }
}

echo json_encode($response);```



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source