Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php header('Access-Control-Allow-Origin: *'); ?>
  2.  
  3. <?php
  4.  
  5. /* Connexion à une base ODBC avec l'invocation de pilote */
  6. $dsn = 'mysql:dbname=catapultedriving_dev;host=localhost';
  7. $user = 'catapultedriving';
  8. $password = 's2sU1vVaFyS0';
  9.  
  10. try {
  11. $dbh = new PDO($dsn, $user, $password);
  12. } catch (PDOException $e) {
  13. echo 'Connexion échouée : ' . $e->getMessage();
  14. }
  15.  
  16. function get_users($db){
  17. $sql='SELECT * FROM users_allowed';
  18.  
  19. $stmt = $db->prepare($sql);
  20.  
  21. $stmt->execute();
  22.  
  23. $users = $stmt->fetchAll();
  24.  
  25. $data = array();
  26.  
  27. $data['users'] = $users;
  28.  
  29. return json_encode($data);
  30. }
  31.  
  32.  
  33.  
  34.  
  35. switch($_GET['function']) {
  36. case 'get_users':
  37. get_users($dbh);
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement