arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL injection
#3
Heart PDO!!

You should use it like this:
PHP Code: (Select All)
<?php
$dsn 
'mysql:dbname=testdb;host=127.0.0.1';
$user 'dbuser';
$password 'dbpass';

try {
 
   $dbh = new PDO($dsn$user$password);
} catch (
PDOException $e) {
 
   echo 'Connection failed: ' $e->getMessage();
}

try {
 
   $query $db->prepare("SELECT * FROM users WHERE username=:user AND password=:password");
 
   $query->execute(['user' => $username'password' => $password]);
 
   if($query->rowCount() > 0) {
 
       echo 'Welcome!!';
 
   } else {
 
       echo 'There is no row with the given credentials.';
 
   }
} catch(
PDOException $e) {
 
   echo 'Database error: ' $e->getMessage();


Although it should work, I have not tested it.


Messages In This Thread
SQL injection - by thispc - 06-03-2016, 09:24 PM
RE: SQL injection - by Rishabh Jain - 06-04-2016, 04:59 PM
RE: SQL injection - by thispc - 06-07-2016, 10:44 PM
RE: SQL injection - by Rishabh Jain - 06-08-2016, 04:53 AM
RE: SQL injection - by thispc - 06-08-2016, 05:50 AM
RE: SQL injection - by Rishabh Jain - 06-08-2016, 08:50 AM
RE: SQL injection - by RickB - 06-06-2016, 08:50 PM
RE: SQL injection - by Vuluts - 10-04-2016, 07:44 PM
RE: SQL injection - by xdude - 10-05-2016, 02:45 AM
RE: SQL injection - by humanpuff69 - 06-05-2017, 02:50 PM
RE: SQL injection - by bookertie - 08-04-2017, 02:06 PM
RE: SQL injection - by Vuluts - 08-04-2017, 02:15 PM
RE: SQL injection - by humanpuff69 - 08-05-2017, 09:23 AM
RE: SQL injection - by Honey - 10-30-2017, 07:21 AM

person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting