· 10 years ago · Feb 23, 2016, 02:51 AM
1<?php
2 $secretKey = "(Key if hashing)";
3 $name = $_REQUEST["name"];
4 $pass = $_REQUEST["pass"];
5 $mail = $_REQUEST["mail"];
6 $hash = $_REQUEST["hash"];
7
8 $servername = "(Server Name)";
9 $username = "(Mysql username)";
10 $password = "(Mysql password)";
11 $dbname = "(Database name)";
12
13 if($name != "" && $pass != "" && $mail != "")
14{
15 // Create connection
16 $conn = mysqli_connect($servername, $username, $password, $dbname);
17 // Check connection
18 if (!$conn) {
19 die("Connection failed: " . mysqli_connect_error());
20 }
21
22 $cpass = mb_convert_encoding($pass . $secretKey, "UTF-32LE");
23 $gpass = md5($cpass);
24 $sql = "INSERT INTO accounts(username, password, email) VALUES ('$name', '$gpass', '$mail')";
25
26 $strUtf32 = mb_convert_encoding($name . $pass . $secretKey, "UTF-32LE");
27 $realhash = md5($strUtf32);
28
29 if($realhash == $hash)
30 {
31 echo "correct key!";
32 if (mysqli_query($conn, $sql)) {
33 echo "Account Created!";
34 } else {
35 echo "Error: " . $sql . "<br>" . mysqli_error($conn);
36 }
37 }
38
39 mysqli_close($conn);
40}
41
42?>