Working with database

I tried like this but I am getting the same error. My DB has fields id, username, email. ID is set as primary key so I think you can omit it when you are inserting new values.

<cfset request.pageTitle = "Registration">

    <!--- Check if the form fields are defined --->
    <cfif IsDefined("form.username") and IsDefined("")>
        <!--- Establish Connection to SQLite Database --->
            <cfquery name="insertUser" datasource="mySQLiteDB">
                INSERT INTO users (username, email)
                VALUES (
                    <cfqueryparam value="#form.username#" cfsqltype="CF_SQL_VARCHAR">,
                    <cfqueryparam value="" cfsqltype="CF_SQL_VARCHAR">

            <!--- Check if the registration was successful --->
            <cfif insertUser.recordCount>
                <p class="style1">Registration successful!</p>
                <p class="style1">Registration failed. Please try again.</p>
        <cfcatch type="database">
            <p class="style1">Database error occurred: #cfcatch.message#</p>
        <p class="style1">Form fields are not defined.</p>

<p align="center" class="style2">REGISTRATION FORM</p>
<p class="style1">In Development process</p>

<div class="reg__container">
    <form class="form__container" method="post">
        <label class="form-label" for="username">Username:</label>
        <input class="form-input" type="text" id="username" name="username" placeholder="Enter your username" required>

        <label class="form-label" for="email">Email:</label>
        <input class="form-input" type="email" id="email" name="email" placeholder="Enter your email" required>

        <div class="form-checkbox-container">
            <input class="form-checkbox" type="checkbox" id="subscribe" name="subscribe">
            <label class="form-label" for="subscribe">Agree to our <a href="#">terms</a> of use.</label>
        <button class="form-button" type="submit">Submit</button>

yes, of course, because you’re making the same mistake: you can’t use recordcount on an insert query:

So what should I use then? I am not familiar with this.

If the insert doesn’t throw an error, it’s safe to assume it was successful.

There are errors mentioned above. But I don’t know how to resolve this

“yes, of course, because you’re making the same mistake: you can’t use recordcount on an insert query”

Ok, this is solved. I fixed it by removing that part of code which checks that thing. :laughing: