Hi, guest!
More
Chat
If you get an error during the chat, please Reload the page !
Simple login page code using Lua scripting
Hello! I would like to share a simple code for a login page using Lua scripting. You are free to style the HTML codes however you want.
The code can be a little challenging to understand at first, but feel free to ask if you don't understand any part.
See also: Simple register page code using Lua scripting

How to use it:
  1. Log in to the Wapka Dashboard (https://web.wapka.org/dashboard);
  2. Select your website from the "Your services" list;
  3. Now create a new page called "login" (Basic Function > New Page) - you can skip this step if you already have a login page and want to use it.
  4. Now open the login page we created and go to Advanced function > Script, and finally paste the following Lua code into the textarea:

Code: Select all

if (env.userid ~= 0) then -- Check if the user is already logged in


url.redirect("/") -- If yes, redirect to the main page end if (req.method == "POST") then -- Checks if the login form has been submitted

error_message = nil -- Starts error message as null

username = req.post.username -- Gets the username from the POST request

password = req.post.password -- Gets the password from the POST request

continue = req.get.continue -- Useful if the user came from another page

if continue == nil then continue = "/" end -- Checks if a continue URL has been defined, if not, it is defined as the home page

if (username == "" and password == "") then -- Checks if the username and password are empty



error_message = "You must enter your username and password."

elseif (username == "") then -- Checks if username is empty



error_message = "You must enter your username."

elseif (password == "") then -- Checks if password is empty



error_message = "You must enter your password."

else -- Continue with login if username and password have been filled in



local param = { -- Sets the parameters for the API login method





username = username,





password = password



}



local is_ok, login, info, error_login = api.user_login(param)



if (is_ok) then -- Username and password are correct and login was successful





url.redirect(continue) -- Redirects to the destination defined in continue



else -- An error occurred while trying to login





error_message = error_login -- defines the error message as the one received in the login method



end

end

if (error_message) then -- Checks if any errors occurred and sets an error message div to display on the page



html_error = [=[<div class="error-message">%s</div>]=]



error_message = string.format(html_error, error_message)

end end local html_code = [=[ <h2>Log-in to your account</h2> %s <!-- This is where the error message will be --> <form method="post"> <div class="input"> <label for="username">Username:</label><br> <input type="text" name="username" value="%s" placeholder="Username" id="username"> </div> <div class="input"> <label for="password">Password:</label><br> <input type="password" name="password" value="%s" placeholder="Password" id="password"> </div> <div class="input-button"> <input type="submit" class="input-button" value="Login"> </div> </form> <div class="register-message"> Not registered yet? <a href="/register">Register</a> </div> ]=] print(string.format(html_code, error_message or "", username or "", password or ""))
Credit - francisco
comment
Media Post - Mobile Friendly
Yuuri - Dried Flower1656263275

hmei7 Published on 2022-06-26 17:07:55 4 years ago
comment
Media Post - Mobile Friendly
wefix.ga1656163062
mario Published on 2022-06-25 13:17:42 4 years ago
comment
Mobile Friendly Post Widget
how to set levels for users based on the points
Hey guys, today am going to share a code with you. With this code, you can set user levels for your site users based on the points they have.







Create a new page called point.Js user lister config: <*id>:VAR(USER_ID).OR.GET(id);<*/id> codes: <*script>{var pt = "%point%" ; if(pt <= 500) {document.write("newbie");}; elseif(pt >= 501 && pt <= 800) {document.write("amateur");};<*/script> You can continue by setting more values and levels. Now in profile add: codes: level: <*script src="/point.js/?id=%id%"><*/script> Now its ready to use.
comment
Mobile Friendly Post Widget
News Feed
Admin/salmon/mario or anyone pls hw do i add shout box pls
comment
Mobile Friendly Post Widget
News Feed
hi plz anyone dat can give me post creator that have coment section plz give me?
comment
Mobile Friendly Post Widget
How to set api data & structure
Hello dev. Today u will know how api spiritually worked. For example: A group,B group,C group. I want to join A group by my id 1234. And i want B,C group to not have my id then <key1>A</key1> <key2>1234</key2>. So let say i want all group to have my id then <key1></key1> <key2>1234</key2>. Another method is i want a post comment lister that store comment,react,reply using one headline here is how it works. <pid>:GET(postid);</pid> <key1>comment</key1>. So if want to comment in each of the comment then <pid>:GET(postid);</pid> <key1>comment</key1> </key2>reply:GET(userid);</key2> in here both post comments count & comments replys count will be combine to gether. look just carmly settle down learn wapka. i also learn wapka too,u r expected to do thesame.
comment
Mobile Friendly Post Widget
News Feed
comment
Mobile Friendly Post Widget
I want this feeds or notification code
I need this code.
comment
Mobile Friendly Post Widget
News Feed
Please how do I get an icon to place in home, notification etc?
comment
Mobile Friendly Post Widget
News Feed
Hello am New here please I have not done anything in my site please i need help
comment
Mobile Friendly Post Widget
News Feed
www.ifunwap.cf - Best wapka site!
comment
Mobile Friendly Post Widget
News Feed
Admin pls i need poptalk theme?
comment
News Feed News Feed [ ] (tanvirahmedjoy)
News Feed News Feed [ ] (hypesloaded)
News Feed News Feed [ ] (hypesloaded)
News Feed News Feed [ ] (hypesloaded)
News Feed News Feed [ ] (charmingdc)
News Feed News Feed [ ] (phlamez)
Category
Statistics
Total posts 837 •Total Files 171 •Total members 392 •Our newest member Hero2026