Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1.  try{
  2.         $username = $_POST['username'];
  3.         $password = $_POST['password'];
  4.         $age = $_POST['age'];
  5.        
  6.         $db = new PDO('mysql:host:localhost;dbname=login','root', '');
  7.         $db_stm = $db->prepare('INSERT INTO users (USERNAME,PASSWORD,AGE)
  8.                                VALUES (:username,:password,:age)');
  9.  
  10.  
  11.         $db_stm->bindParam('username', $username);
  12.         $db_stm->bindParam('password', $password);
  13.         $db_stm->bindParam('age', $age);
  14.  
  15.         $db_stm->execute();
  16.  
  17.         echo $db->lastInsertId();
  18.     }
  19.     catch(PDOException $exception){
  20.         throw new Exception($exception->getMessage(),$exception->getCode());
  21.     }
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement