Advertisement
DKHHACKLEMON

Register.php

Apr 22nd, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. function ExitAlert($msg){
  3.     exit("gg.alert('".$msg."')");
  4. }
  5.  
  6. $JDecode = json_decode(file_get_contents('php://input'),true);
  7. $FileName = "LoginData.data";
  8. $username= $JDecode["Username"];
  9. $password=  $JDecode["Password"];
  10. $confirm_password= $JDecode["ConfirmPassword"];
  11. $content =json_decode(file_get_contents($FileName),true);
  12. if ($content == null){
  13. $content =[];
  14. }
  15. if(isset($username) == false || isset($password)== false ||trim($password) == ""|| trim($username) == ""){
  16. ExitAlert('Invalid username or password');
  17. }
  18. if($confirm_password <>$password){
  19. ExitAlert('The password field and confirm password should match, try again');
  20. }
  21. if($content[$username] == null){
  22.     $content[$username] =  array(
  23.     "password" => $password);
  24.     file_put_contents($FileName,json_encode($content,true));
  25.     ExitAlert("User successfully registered!!!");
  26.     }
  27.     else{
  28.         ExitAlert("This username already exists, try another");
  29.         }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement