Advertisement
Guest User

AJAX Chat Register Code

a guest
Jul 23rd, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8. <head>
  9. <meta charset="UTF-8">
  10. <title>Register to chat</title>
  11. <link type="text/css" rel="stylesheet" href="css/MyBB.css">
  12. </head>
  13. <body>
  14. <form method="post" onclick="register.php">
  15. Username: <input type="text" name="username">
  16. Password: <input type="password" name="password">
  17. Confirm Password: <input type="password" name="passconf">
  18. <input type="submit" value="Submit!">
  19. </form>
  20. <?php
  21. if (!empty($_POST)) {
  22. $password = $_POST['password'];
  23. $passconf = $_POST['passconf'];
  24. if ($pasword == $passconf) {
  25. $idFile = fopen("lib/id.txt", "r") or die("Error: Unable to open id file. Please try again. If this error persists, consult the Head Admin.");
  26. $id = fread($idFile, filesize("lib/id.txt"));
  27. $id = $id + 1;
  28. fclose($idFile);
  29. $idf2 = fopen("lib/id.txt", "r") or die("Error: Unable to open id file. Please try again. If this error persists, consult the Head Admin.");
  30. fwrite($idf2, $id);
  31. fclose($idf2);
  32. $userFile = fopen("lib/data/users.php", "a+") or die("Error: Unable to open users file. Please try again. If this error persists, consult the Head Admin");
  33. fwrite($userFile, '\n$users[' . $id . '] = array();\n' . '$users[' . $id . '][\'userRole\'] = AJAX_CHAT_USER;\n' . '$users[' . $id . '][\'userName\'] = \'' . $_POST['username'] . '\';\n' . '$users[' . $id . '][\'password\'] = \'' . $_POST['password'] . '\';\n' . '$users[\'' . $id . '\'][\'channels\'] = array(0,1);\n');
  34. echo "<br>Your user has been created. Click <a href=\"index.php\">here</a> to login.<br>";
  35. } else {
  36. echo "<br><span style=\"color:red;\">Your password does not match your confirmation of your pasword. Please try again.</span><br>";
  37. }
  38. }
  39. ?>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement