Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local composer = require( "composer" )
- local scene = composer.newScene()
- local widget = require("widget")
- -- forward declare the text fields
- local mime = require("mime")
- local json = require("json")
- local username
- local password
- local email
- local function handleButtonEvent( event )
- if ( "ended" == event.phase ) then
- local URL = "http://hash.comxa.com/register.php?username=" .. ( username.text ) .. "&password=" .. mime.b64(password.text) .. "&email=" .. mime.b64( email.text )
- network.request(URL, "GET", networkListener)
- else
- print( "Something went wrong. Try again.")
- end
- end
- local function loginLink( event )
- if ( "ended" == event.phase ) then
- composer.gotoScene("login")
- end
- end
- local function networkListener( event )
- print(json.encode(event))
- composer.gotoScene("login")
- end
- function scene:create(event)
- local screenGroup = self.view
- display.setDefault("background", 0, 3, 5)
- local icon = display.newImage("hash_opt.png", 160, 70)
- screenGroup:insert(icon)
- username = native.newTextField( 160, 200, 180, 30 ) -- take the local off since it's forward declared
- username.placeholder = "Username"
- screenGroup:insert(username)
- password = native.newTextField( 160, 250,180, 30 ) -- take the local off since it's forward declared
- password.isSecure = true
- password.placeholder = "Password"
- screenGroup:insert(password)
- password2 = native.newTextField( 160, 300,180, 30 ) -- take the local off since it's forward declared
- password2.isSecure = true
- password2.placeholder = "Confirm Password"
- screenGroup:insert(password2)
- email = native.newTextField( 160, 350, 180, 30 ) -- take the local off since it's forward declared
- email.placeholder = "E-mail"
- screenGroup:insert(email)
- local Button = widget.newButton(
- {
- shape = "roundedRect",
- left = 70,
- top = 400,
- id = "Register",
- label = "Register",
- onEvent = userRegister
- }
- )
- screenGroup:insert(Button)
- local Button2 = widget.newButton(
- {
- left = 70,
- top = 460,
- id = "Loginhere",
- label = "Login here",
- onEvent = loginLink
- }
- )
- screenGroup:insert(Button2)
- end
- function scene:show(event)
- end
- function scene:hide(event)
- end
- function scene:destroy(event)
- end
- scene:addEventListener("create", scene)
- scene:addEventListener("show", scene)
- scene:addEventListener("hide", scene)
- scene:addEventListener("destroy", scene)
- return scene
- if ($_GET['password'] == $_GET['password2']) {
- $username = $_GET['username'];
- $password = base64_decode( $_GET['password']);
- $password2 = ( $_GET['password2']);
- $email= base64_decode( $_GET['email']);
- // validate and sanitize all of these inputs
- // and see that they are not blank at the same time
- // Do your MySqli here to find the $username and
- // bring out result of find in $username_result
- $sql = "SELECT * FROM users WHERE username='" . $username . "' AND email='" . $email . "'";
- if(mysqli_num_rows($sql) > 0)
- {
- echo "User exist";
- } else {
- // it is not in use so put it in
- $sql = "INSERT INTO users (username, password, email) VALUES ('" . $username. "', '" . $password . "', '" . $email. "')";
- if(mysqli_query($con, $sql)){
- }else{
- echo "Sorry something went wrong.";
- }
- }
- }else{
- echo "Passwords don't match.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement