Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. local composer = require( "composer" )
  2. local scene = composer.newScene()
  3.  
  4. local widget = require("widget")
  5. -- forward declare the text fields
  6. local mime = require("mime")
  7. local json = require("json")
  8.  
  9. local username
  10. local password
  11. local email
  12.  
  13. local function handleButtonEvent( event )
  14. if ( "ended" == event.phase ) then
  15. local URL = "http://hash.comxa.com/register.php?username=" .. ( username.text ) .. "&password=" .. mime.b64(password.text) .. "&email=" .. mime.b64( email.text )
  16. network.request(URL, "GET", networkListener)
  17.  
  18. else
  19. print( "Something went wrong. Try again.")
  20. end
  21. end
  22.  
  23. local function loginLink( event )
  24. if ( "ended" == event.phase ) then
  25. composer.gotoScene("login")
  26. end
  27. end
  28.  
  29. local function networkListener( event )
  30. print(json.encode(event))
  31. composer.gotoScene("login")
  32. end
  33.  
  34. function scene:create(event)
  35. local screenGroup = self.view
  36.  
  37. display.setDefault("background", 0, 3, 5)
  38.  
  39. local icon = display.newImage("hash_opt.png", 160, 70)
  40. screenGroup:insert(icon)
  41.  
  42. username = native.newTextField( 160, 200, 180, 30 ) -- take the local off since it's forward declared
  43. username.placeholder = "Username"
  44. screenGroup:insert(username)
  45.  
  46. password = native.newTextField( 160, 250,180, 30 ) -- take the local off since it's forward declared
  47. password.isSecure = true
  48. password.placeholder = "Password"
  49. screenGroup:insert(password)
  50.  
  51. password2 = native.newTextField( 160, 300,180, 30 ) -- take the local off since it's forward declared
  52. password2.isSecure = true
  53. password2.placeholder = "Confirm Password"
  54. screenGroup:insert(password2)
  55.  
  56. email = native.newTextField( 160, 350, 180, 30 ) -- take the local off since it's forward declared
  57. email.placeholder = "E-mail"
  58. screenGroup:insert(email)
  59.  
  60. local Button = widget.newButton(
  61. {
  62. shape = "roundedRect",
  63. left = 70,
  64. top = 400,
  65. id = "Register",
  66. label = "Register",
  67. onEvent = userRegister
  68. }
  69. )
  70. screenGroup:insert(Button)
  71.  
  72.  
  73. local Button2 = widget.newButton(
  74. {
  75. left = 70,
  76. top = 460,
  77. id = "Loginhere",
  78. label = "Login here",
  79. onEvent = loginLink
  80. }
  81. )
  82. screenGroup:insert(Button2)
  83.  
  84. end
  85.  
  86. function scene:show(event)
  87. end
  88.  
  89. function scene:hide(event)
  90. end
  91.  
  92. function scene:destroy(event)
  93. end
  94.  
  95. scene:addEventListener("create", scene)
  96. scene:addEventListener("show", scene)
  97. scene:addEventListener("hide", scene)
  98. scene:addEventListener("destroy", scene)
  99.  
  100. return scene
  101.  
  102. if ($_GET['password'] == $_GET['password2']) {
  103. $username = $_GET['username'];
  104. $password = base64_decode( $_GET['password']);
  105. $password2 = ( $_GET['password2']);
  106. $email= base64_decode( $_GET['email']);
  107.  
  108.  
  109. // validate and sanitize all of these inputs
  110. // and see that they are not blank at the same time
  111.  
  112. // Do your MySqli here to find the $username and
  113. // bring out result of find in $username_result
  114.  
  115. $sql = "SELECT * FROM users WHERE username='" . $username . "' AND email='" . $email . "'";
  116.  
  117. if(mysqli_num_rows($sql) > 0)
  118. {
  119. echo "User exist";
  120. } else {
  121.  
  122. // it is not in use so put it in
  123.  
  124. $sql = "INSERT INTO users (username, password, email) VALUES ('" . $username. "', '" . $password . "', '" . $email. "')";
  125.  
  126. if(mysqli_query($con, $sql)){
  127. }else{
  128. echo "Sorry something went wrong.";
  129. }
  130. }
  131. }else{
  132. echo "Passwords don't match.";
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement