Advertisement
berzerker101a

ACS.php

Feb 19th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2.     /*
  3.         ACS (Account Creation Server) v1.0 by Berzerker
  4.        
  5.         Rules:
  6.         -Usernames may not have special characters
  7.         -Passwords have no limitations
  8.         -The app itself checks if a username is already taken
  9.        
  10.         Packet Format:
  11.         <packet>
  12.             <username>Username</username>
  13.             <password>Password</password>
  14.         </packet>
  15.     */
  16.    
  17.     //Start connect to MySQL database
  18.     $servername = "SERVER NAME"; //Change this
  19.     $usernameSQL = "USERNAME"; //Change this
  20.     $passwordSQL = "PASSWORD"; //Change this
  21.     $conn = new mysqli($servername, $usernameSQL, $passwordSQL);
  22.     //End connect to MySQL database
  23.    
  24.     $packetRecieved=$_POST["messagePacket"]; //Recieves the message from the app
  25.     $xmlUnparsed=new SimpleXMLElement($packetRecieved);
  26.    
  27.     //Start XML parsing
  28.     $xmlUsername=$xmlUnparsed->username;
  29.     $xmlPassword=$xmlUnparsed->password;
  30.     //End XML parsing
  31.    
  32.     //Start sanatizing input
  33.     $sanatizedUsername=filter_var($xmlUsername, FILTER_SANITIZE_STRING);
  34.     $sanatizedPassword=filter_var($xmlPassword, FILTER_SANITIZE_STRING);
  35.     //End sanatizing input
  36.    
  37.     //Start add account to database
  38.     $username=$sanatizedUsername;
  39.     $password=$sanatizedPassword;
  40.    
  41.     $getNewestId="SELECT LAST(id) FROM accounts;";
  42.     $id=$getNewestId+1;
  43.     $sqlUpdate="INSERT INTO accounts (id,username,password) VALUES ('$id','$username','$password');";
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement