Skip to content

Instantly share code, notes, and snippets.

@CloudyWater
Last active January 29, 2017 19:12
Show Gist options
  • Save CloudyWater/c1780c209c2fa6f3514f9fe43879d5c2 to your computer and use it in GitHub Desktop.
Save CloudyWater/c1780c209c2fa6f3514f9fe43879d5c2 to your computer and use it in GitHub Desktop.
Adds a user to our database
<?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