Asslam o Alaikum, 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
New video1654550052
sndyvai Published on 2022-06-06 21:14:12 4 years ago
comment
Media Post - Mobile Friendly
Panel Mode1653456113
webmash Published on 2022-05-25 05:21:53 4 years ago
comment
Mobile Friendly Post Widget
News Feed
I just figured out how to submit an API Data Creator using an external PHP site with post request. I see many applications for this...
comment
Mobile Friendly Post Widget
News Feed
Wapka sitemap submission not working on Google webmaster.. you can submit your website but can't submit your site map
comment
Mobile Friendly Post Widget
News Feed
Someone should help me with download page theme key
comment
Mobile Friendly Post Widget
News Feed
Someone should help me with download page theme...
comment
Mobile Friendly Post Widget
News Feed
Please I need this site, point code when you login
comment
Mobile Friendly Post Widget
how to make user claim points once a day
Guys this is a small task. How it works: On the login page, user clicks on the enter btn and then it automatically add 50 points to the user's account and redirects the user to the home page so that user cannot cheat. ON the login page go to user lister: config: <*userid>:VAR(USER_ID);<*/userid> Codes: :VALUE(%point%).SET(points).NULL; user editor: Config: <*userid>:VAR(USER_ID);<*/userid> <*set_var_date>:POST(date);<*/set_var_date> <set_point>:POST(points);<*/set_point> Codes: :DATE(D).SET(date).NULL; :VALUE(%notify%).IFEQ(Success).THEN.NULL.ELSE.NULL;<*br><*input type="hidden" name="date" value=":VAR(date);"><*input type="hidden" name="points" value=":VAR(points).PLUS(50);"><*br>:VAR(date).IFNE.DATE(D).THEN(<*input type="submit" value="claim 50 points">).ELSE(You have successfully claim 50 pts; come back for more tomorrow);<*br><*button onclick="home">enter<*/button>); you are good to go
comment
Mobile Friendly Post Widget
how to set user avatar
Please somebody help me with setting uses avatar. Using user editor
comment
Mobile Friendly Post Widget
page patterns
Please some one should explain page pattern to me
comment
Mobile Friendly Post Widget
icon pack
Download your icons from this site: https://iconfinder.com
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
News Feed News Feed [ ] (hypesloaded)
News Feed News Feed [ ] (hypesloaded)
News Feed News Feed [ ] (Ridoyahmed)
News Feed News Feed [ ] (Userdeleted)
News Feed News Feed [ ] (tanvirahmedjoy)
News Feed News Feed [ ] (tanvirahmedjoy)
News Feed News Feed [ ] (tanvirahmedjoy)
Category
Statistics
Total posts 836 •Total Files 167 •Total members 391 •Our newest member abhijeet