Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Include('Connect.php');
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- $main_password "";
- $message = "";
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- function Usernamequery($connection,$username){
- $arrayUsername = array();
- $result = mysqli_query($connection, "SELECT * FROM `Members_Information` WHERE username = '$username'");
- if($result == true){
- while($row = mysqli_fetch_array($result))
- $arrayUsername = $row['Username'];
- }if ($arrayUsername == $username){
- return true;
- }else{
- return false;
- }
- }
- function Emailquery($connection,$email){
- $arrayemail = array();
- $result = mysqli_query($connection, "SELECT * FROM `Members_Information` WHERE email = '$email'");
- if($result == true){
- while($row = mysqli_fetch_array($result))
- $arrayemail = $row['email'];
- }if ($arrayemail == $email){
- return true;
- }else{
- return false;
- }
- }
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["username"]) == false) {
- $username = test_input($_POST["username"]);
- if (empty($_POST["password1"])== false) {
- $password1 = test_input($_POST["password1"]);
- if (empty($_POST["password2"]) == false) {
- $password2 = test_input($_POST["password2"]);
- if (empty($_POST["email"]) == false) {
- $email = test_input($_POST["email"]);
- if (Usernamequery($connection, $username) == false){
- if (Emailquery($connection, $email) == false){
- if ($password1 == $password2){
- $password1 = $password;
- if (strlen($password) >= 6 && strlen($password) <= 15){
- $pepper = "Jg"; // USED TO ADD A CONSISTENT PEPPER TO ALL PASSWORDS
- $characters = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
- $randomString = '';
- $length = 8;
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, strlen($characters) - 1)];
- }
- $salt = $randomString;
- // HASH PASSWORD
- $main_password = trim($password);
- $main_password = bin2hex(mhash(MHASH_MD5, sha1($main_password.$pepper)));
- $main_password = $salt.$main_password;
- $active = 0 ;
- $sql = $connection->prepare("INSERT INTO Members_Information(Id, Password, Username, Email, UserId, Active) VALUES (Id,?,?,?,?,?)");
- $sql->bind_param('sss', $main_password, $username, $email, $userId, $active);
- $sql->execute();
- $sql->close();
- }else {$message ="Password needs to have more then 6 characters but less than 16";}
- }else {$message = "Passwords are not the same!";}
- }else { $message = "Please use a different Email!";}
- }else { $message = "Please choose a different Username!";}
- }else { $message = "Email is required!";}
- }else { $message = "Password is required!";}
- }else { $message = "Password is required!";}
- }else { $message = "Username is required!";}
- } else{ $errormessage = "Data Not Found!";}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement