Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(-1);
  4. ini_set('display_errors', 1);
  5.  
  6. $serverName = "";
  7. $userName = "";
  8. $password = "";
  9. $dbName = "";
  10.  
  11. $isPHPAuth = false;
  12.  
  13. try
  14. {
  15. $myPDO = new PDO("mysql:host=$serverName;dbname=$dbName;charset=latin1", $userName, $password);
  16. $myPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  17. $isPHPAuth = true;
  18. }
  19.  
  20. catch(exception $e)
  21. {
  22. echo("Unable to Connect" . $e->getMessage());
  23. }
  24.  
  25. if ($isPHPAuth)
  26. {
  27. try
  28. {
  29. if (isset($_GET["selection"]))
  30. {
  31. $username = $_GET['username'];
  32.  
  33. $stm = $myPDO->prepare("SELECT * FROM mediasystem_purchases WHERE customer name == :parameter;");
  34. $stm->bindParam(':parameter', $username, PDO::PARAM_STR); // injection protection way of using variables in statements
  35. $stm->execute();
  36.  
  37. while($result = $stm->fetch(PDO::FETCH_ASSOC))
  38. {
  39. print('ID: '$result['id']);
  40.  
  41. }
  42. }
  43. else
  44. {
  45. echo("ERROR: GET NOT SET...");
  46. }
  47. }
  48. Catch(Exception $e)
  49. {
  50. echo("statement error: " . $e->getMessage());
  51. }
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement