Advertisement
Guest User

Untitled

a guest
May 24th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.80 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # PERL MODULES WE WILL BE USING
  4. use DBI;
  5. use DBD::mysql;
  6.  
  7. # HTTP HEADER
  8. print "Content-type: text/html \n\n";
  9.  
  10. # CONFIG VARIABLES
  11. $platform = "mysql";
  12. $host = "localhost";
  13. $database = "datachk";
  14. $tablename = "usuario";
  15. $user = "root";
  16. $password = "root";
  17.  
  18.  
  19. # DATA SOURCE NAME
  20. $dsn = "dbi:mysql:$database:localhost:3306";
  21.  
  22. # PERL DBI CONNECT
  23. $connect = DBI->connect($dsn, $user, $password);
  24.  
  25. # PREPARE THE QUERY
  26. $query = "SELECT * FROM usuario ORDER BY cpf";
  27. $query_handle = $connect->prepare($query);
  28.  
  29. # EXECUTE THE QUERY
  30. $query_handle->execute();
  31.  
  32. # BIND TABLE COLUMNS TO VARIABLES
  33. $query_handle->bind_columns(undef, \$cpf, \$nome, \$nivel, \$login, \$senha);
  34.  
  35. # LOOP THROUGH RESULTS
  36. while($query_handle->fetch()) {
  37.    print "$cpf, $nome, $nivel, $login <br />";
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement