Last active
January 29, 2017 19:12
-
-
Save CloudyWater/c1780c209c2fa6f3514f9fe43879d5c2 to your computer and use it in GitHub Desktop.
Adds a user to our database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db = mysql_connect('localhost', 'username', 'password') or die ('Could not connect: ' . mysql_error()); | |
mysql_select_db('databasename') or die ('Could not select database'); | |
$email = mysql_real_escape_string($_GET['email'], $db); | |
$username = mysql_real_escape_string($_GET['username'], $db); | |
$password = mysql_real_escape_string($_GET['password'], $db); | |
$hash = $_GET['hash']; | |
$secretKey = 'secretkey'; | |
$real_hash = md5($email . $username . $password . $secretKey); | |
if ($real_hash == $hash) | |
{ | |
$query = "INSERT INTO users (username, password, creationdate, email) values ('$username', '$password', NOW(), '$email');"; | |
$result = mysql_query($query) or die('Query failed: ' . mysql_error()); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment