Advertisement
Dalon

Inserir em mysql+PDO

Mar 24th, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1. <?php
  2. $nome = var_dump($_POST['nome']);
  3. $email = var_dump($_POST['email']);
  4.  
  5.  
  6.  
  7. $username="root";
  8. $password="admin";
  9.  
  10. if($link = new PDO('mysql:host=localhost;dbname=pesquisas', $username, $password)){
  11.     echo "ok";
  12. };
  13. $sql = "INSERT INTO contatos (nome, email) VALUES (?, ?)";
  14. $sqlpre = $link->prepare($sql);
  15. $sqlarray = array("$nome", "$email");
  16. if($sqlpre->execute($sqlarray)){
  17. echo "   feito";
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement