Quantcast
Channel: Lucee Dev - Latest topics
Viewing all articles
Browse latest Browse all 473

Working with database

$
0
0

My friend wants to have SQLite on his website and he created folder for it in “/MembersOnly/DatabaseFiles/users.sqlite”

My structure looks like this:

/root
/Register/index.cfm
/MembersOnly/DatabaseFiles/users.sqlite

This is the code I am trying to use but it doesn’t work:

<cfset request.pageTitle = "Registration">

<!--- Define the relative path to your SQLite database file --->
<cfset database_path = "../MembersOnly/DatabaseFiles/users.sqlite">

<cfif IsDefined("form.username") and IsDefined("form.email")>
    <!--- Establish Connection to SQLite Database --->
    <cfquery name="insertUser" datasource="#database_path#">
        INSERT INTO users (username, email)
        VALUES (
            <cfqueryparam value="#form.username#" cfsqltype="CF_SQL_VARCHAR">,
            <cfqueryparam value="#form.email#" cfsqltype="CF_SQL_VARCHAR">
        )
    </cfquery>

    <!--- Check if the registration was successful --->
    <cfif insertUser.recordCount>
        <p class="style1">Registration successful!</p>
    <cfelse>
        <p class="style1">Registration failed. Please try again.</p>
    </cfif>
</cfif>

<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 out <a href="#">terms</a> of use.</label>
        </div>
        <button class="form-button" type="submit">Submit</button>
    </form>
</div>

I am trying to access this users.sqlite db from index.cfm file but I keep getting error.

Don’t forget to tell us about your stack!

OS: Windows 10

8 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 473

Trending Articles