sql example

From xrobau, 2 Years ago, written in PHP, viewed 3 times.
URL https://pastebin.freepbx.org/view/1bac2342 Embed
Download Paste or View Raw
  1. $host = "localhost";
  2. $dbname = "testdb";
  3. $dbport = "";
  4.  
  5. $user = "username";
  6. $pass = "password";
  7.  
  8. $dsn = "mysql:host=$dbhost;dbname=$dbname;charset=utf8$dbport";
  9.  
  10. $dbh = new \PDO($dns, $user, $pass);
  11.  
  12. $sth = $dbh->prepare("SELECT id FROM users WHERE usename=? AND pasword=?");
  13.  
  14. $sth->execute([ $_POST['username'], $_POST['password'] ]);
  15.  
  16. var_dump($sth->fetchAll(\PDO::FETCH_ASSOC));
  17.  

Reply to "sql example"

Here you can reply to the paste above