Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <?php header("Access-Control-Allow-Origin:*"); // Allow all origins
  2.  
  3. $InputAction = $_POST["Action"]; // Eventhandler
  4.  
  5. if ($InputAction == "Register") {
  6. echo("-400") } ?>
  7.  
  8. XMLHttpRequest cannot load http://api.proxy.wtf/debug.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.14:50001' is therefore not allowed access. The response had HTTP status code 500.
  9.  
  10. <?php
  11. header("Access-Control-Allow-Origin:*"); // Allow all origins
  12.  
  13. require('includes/config.php'); // Prerequisite
  14.  
  15. /** Numeric callbacks (!negative values!)
  16. -200 Registration successful; validation mail sended
  17. -250 Username OK
  18.  
  19. -300 Username too short
  20. -301 Username already in use
  21. -302 Password too short
  22. -303 Invalid email address
  23. -304 Email already in use
  24. -305 Error while registration
  25.  
  26. -400 Illegal request
  27. **/
  28.  
  29. $InputAction = $_POST["Action"]; // Eventhandler
  30.  
  31. $InputUsername = $_POST["Username"]; // Requesting username
  32. $InputMailaddress = $_POST["Mailaddress"]; // Requesting mail address
  33. $InputPassword = $_POST["Password"]; // Requesting password
  34.  
  35. if ($InputAction == "Register") { // Action: Register
  36. if(strlen($InputUsername) < 3){ // Check Username length
  37. $error[] = 'Username is too short.';
  38. echo("-300");
  39. } else { // Check if username already exists
  40. $stmt = $db->prepare('SELECT username FROM members WHERE username = :username');
  41. $stmt->execute(array(':username' => $InputUsername));
  42. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  43. echo("-250");
  44.  
  45. if(!empty($row['username'])){ // If username already taken
  46. $error[] = 'Username provided is already in use.';
  47. echo("-301");
  48. }
  49. }
  50. }
  51. else {
  52. echo("-400");
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement