Advertisement
Guest User

Untitled

a guest
Jun 20th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. /* Initialize an array for filtered data. */
  2. $clean = array();
  3. /* Define a salt. */
  4. define('SALT', 'flyingturtle');
  5. /* Encrypt the password. */
  6. $encrypted_password = md5(SALT . $_POST['password']);
  7. /* Allow alphanumeric usernames. */
  8. if (ctype_alnum($_POST['username'])) {
  9. $clean['username'] = $_POST['username'];
  10. } else {
  11. /* Error */
  12. }
  13. /* Store user in the database. */
  14. $st = $db->prepare('INSERT
  15. INTO
  16. users (username, password)
  17. VALUES (?, ?)');
  18. $st->execute(array($clean['username'], $encrypted_password));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement