Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $fullname = $_POST['name'];
- $pmcUsername = $_POST['pmc'];
- $mysqli = new mysqli(-snip-);
- $username = $mysqli->real_escape_string($username);
- $password = $mysqli->real_escape_string($password);
- $email = $mysqli->real_escape_string($email);
- $fullname = $mysqli->real_escape_string($fullname);
- $pmcUsername = $mysqli->real_escape_string($pmcUsername);
- if ($mysqli->connect_error) {
- die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
- }
- $result = $mysqli->query("SELECT username, email, pmcUsername FROM `users`");
- if(!$result){
- die('There was an error running the query [' . $mysqli->error . ']');
- }
- $hasFound = false;
- while($row = $result->fetch_assoc()){
- if ($row['username']==$username) {
- $hasFound = true;
- }
- if ($row['email']==$email) {
- $hasFound = true;
- }
- if ($row['pmcUsername']==$pmcUsername) {
- $hasFound = true;
- }
- }
- $result->free();
- if ($username.isSet()) {
- $hasFound = true;
- }
- if ($password.isSet()) {
- $hasFound = true;
- }
- if ($email.isSet()) {
- $hasFound = true;
- }
- if ($fullname.isSet()) {
- $hasFound = true;
- }
- if ($pmcUsername.isSet()) {
- $hasFound = true;
- }
- if ($hasFound==false) {
- $salt = uniqid($username, true);
- $encryptedPassword = crypt($password, $salt);
- $datentime = $mysqli->real_escape_string(date('Y/m/d H:i:s'));
- $result = $mysqli->query("INSERT INTO `users` (`username`, `password`, `email`, `name`, `accessToken`, `pmcUsername`, `minecraftUsername`, `registeredTime`) VALUES ('".$username."', '".$encryptedPassword."', '".$email."', '".$fullname."', '', '".$pmcUsername."', '', '".$datentime."')");
- if(!$result){
- die('There was an error running the query [' . $mysqli->error . ']');
- }
- }
- $mysqli->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement