Advertisement
Guest User

Untitled

a guest
Jul 7th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. <?php
  2.  
  3. $dns = "mysql:dbname=blog;host=localhost";
  4. $dbuser = "root";
  5. $dbpass = "";
  6.  
  7. try{
  8.  
  9. $pdo = new PDO($dns, $dbuser, $dbpass);
  10.  
  11. $nome = "Testador2";
  12. $email = "testador2@hotmail.com";
  13. $senha = md5("123");
  14. $sql = "INSERT INTO usuarios SET nome = '$nome', email = '$email', senha = '$senha'";
  15. $sql = $pdo->query($sql);
  16.  
  17. echo "usuario inserido com sucesso".$pdo->lastInsertId();
  18.  
  19. }catch(PDOException $e){
  20.  
  21. echo "Falhou ".$e->getMessage();
  22.  
  23. }
  24.  
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement