Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. $error = '';
  3. if (isset ($_POST ['u']) && isset ($_POST ['p']) && isset ($_POST ['ap']))
  4. {
  5. $userName = $_POST ['u'];
  6. if ($userName == '')
  7. $error = 'Error: no username entered';
  8. else
  9. {
  10. $password = $_POST ['p'];
  11. if ($password == '')
  12. $error = 'Error: no password entered';
  13. else
  14. {
  15. $adminPassword = $_POST ['ap'];
  16. if (md5 ($adminPassword) == 'b34bb3a5f5241a061737bba8a691538e')
  17. {
  18. if (isset ($_POST ['r'])) $userRole = $_POST ['r'];
  19. else $userRole = '1';
  20. $_config ['host'] = 'localhost';
  21. $_config ['user'] = '*';
  22. $_config ['pass'] = '*';
  23. $_config ['name'] = '*';
  24. mysql_select_db ($_config ['name'], ($_link = mysql_connect ($_config ['host'], $_config ['user'], $_config ['pass'], true)));
  25. $_result = mysql_query ("INSERT INTO `users` (`id`, `userName`, `password`, `userRole`) VALUES (NULL, '" . $userName . "', '" . $password . "', '" . $userRole . "');");
  26. }
  27. }
  28. }
  29. }
  30. ?>
  31. <html>
  32. <head>
  33. <body bgcolor=Purple>
  34. <title>Add AJAX Chat User</title>
  35. </head>
  36. <body>
  37. <div align = "center">
  38. <div align = "center" style = "border: 1px solid; width: 50%">
  39. <form action = "" method = "POST">
  40. <span style = "font-size: 1.5em; font-weight: bold">Add user</span><br/>
  41. <?php
  42. if ($error != '') echo '<span style = "color: red; font-weight: bold">' . $error . '</span><br />';
  43. ?>
  44. Username: <input type = "text" name = "u" /><br />
  45. Password: <input type = "text" name = "p" /><br />
  46. User role¹: <input type = "text" name = "r" /><br />
  47. Administrative password²: <input type = "text" name = "ap" /><br />
  48. <input type = "submit" value = "Add" /><br />
  49. ¹ 1 = regular user; 2 = moderator; 3 = administrator<br />
  50. ² Your admin password, to prevent script abuse
  51. <h6> script courtesy of TheXDarksider</h6>
  52. </form>
  53. </div>
  54. </div>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement