Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. -- Submit network request
  2. --
  3. local function submitButtonPress (event)
  4. --print ("submitButtonPress")
  5. local URL
  6. local info
  7.  
  8. -- Get data to check if it already exists
  9. -- Get data by email specified
  10.  
  11. -- Set up HTTP request:
  12. local headers = {}
  13. headers[ "Content-Type" ] = "application/x-www-form-urlencoded"
  14.  
  15. --print ("username: " .. usernameText.text)
  16. --print ("email: " .. emailText.text)
  17. --print ("password: " .. passwordText.text)
  18.  
  19. local URL
  20. local info
  21.  
  22. -- Encryption (MD5)
  23. local password = crypto.digest (crypto.md5, passwordText.text)
  24.  
  25. info = "&email=" .. string.urlEncode (emailText.text) .. "&password=" .. password .. "&status=" .. status .. "&username=" .. string.urlEncode (usernameText.text)
  26.  
  27. local params = {}
  28. params.headers = headers
  29. params.body = info
  30.  
  31. -- Post data with specified info stored in the "info" var
  32. if info ~= "" then
  33. URL = "http://localhost:5723/users_post.php"
  34. network.request (URL, "POST", networkListenerPost, params)
  35. else
  36. print ("info to post is empty")
  37. end
  38. end
  39.  
  40. -- Back to menu
  41. --
  42. local function menuButtonPress (event)
  43. print ("menuButtonPress")
  44. composer.gotoScene ("login", "slideRight", 300)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement