Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2.  
  3. // Set up databank connection
  4. require_once '../../php/DBconfig.php';
  5.  
  6. // Define variables and initialize with empty values
  7. $fields = array("username","password","confirm_password","firstname","lastname","email","confirm_email","birthday","gender");
  8. $params = array();
  9. $param_errs = array();
  10. $param_valid = array();
  11. foreach ($fields as &$v1) {
  12. $params[$v1] = "";
  13. $param_errs[$v1] = "";
  14. $param_valid[$v1] = FALSE;
  15. }
  16.  
  17. // Processing form data when form is submitted
  18. if($_SERVER["REQUEST_METHOD"] == "POST") {
  19.  
  20. foreach ($fields as &$v1) {
  21. echo $v1;
  22. $params[$v1] = trim($_POST[$v1]);
  23. }
  24.  
  25. // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  26. $validateUsername = function ($params, $param_errs, $param_valid, $link /*DB*/) {
  27. /*validates if the entered username is valid (by calling $params["username"],
  28. if not valid, put error message in $param_errs["username"],
  29. if valid, $param_valid["username"] = True; */
  30. };
  31. $validatePassword = function ($params, $param_errs, $param_valid) {
  32. //checks if the entered password is valid
  33. };
  34. $validateConfirmPassword = function ($params, $param_errs, $param_valid) {
  35. //checks if the entered password matches the first one
  36. };
  37.  
  38. $validator = array(
  39. "username" => $validateUsername,
  40. "password" => $validatePassword,
  41. "confirm_password" => $validateConfirmPassword
  42. );
  43. // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  44.  
  45. // validates all fields
  46. foreach ($fields as &$v1) {
  47. $validator[$v1]($params, $param_errs, $param_valid, $link);
  48. }
  49.  
  50. // Check input errors before inserting in database
  51. if (!in_array(False, $param_valid)) {
  52. // registers new user
  53. }
  54. }
  55. ?>
  56.  
  57.  
  58.  
  59. <!DOCTYPE html>
  60. <html lang="en">
  61. <head>
  62. <!-- left out this code -->
  63. </head>
  64.  
  65. <body>
  66. <!-- left out this code, register form is here -->
  67. </body>
  68.  
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement