IvoSilva

CreateUser

Apr 27th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. function createUser($username, $password, $firstname, $lastname, $genre, $email, $mobile, $birthdate)
  2.     {
  3.         global $conn;
  4.         $stmt = $conn->prepare
  5.         ("
  6.            INSERT INTO utilizador (utilizador, palavrapasse, nomeproprio, sobrenome, genero, email, telefone, datanascimento, dataregisto)
  7.            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
  8.            RETURNING idutilizador
  9.        ");
  10.         $currentdate = date("Y-m-d");
  11.         $stmt->execute(array($username, sha1($password), $firstname, $lastname, $genre, $email, $mobile, $birthdate, $currentdate));
  12.         $idutilizador = $stmt->fetch(PDO::FETCH_ASSOC);
  13.        
  14.         $stmt = $conn->prepare
  15.         ("
  16.            INSERT INTO utilizadornormal
  17.            VALUES (?)
  18.        ");
  19.         $stmt->execute(array($idutilizador));
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment