Advertisement
Guest User

Untitled

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