Guest User

Untitled

a guest
Jan 3rd, 2018
142
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. class conexao{
  3.  
  4. var $connect;
  5. var $con_string = "host=localhost/TCC port=5432 dbname=TCC user=postgres password=123456";
  6.  
  7.  
  8. function conexao(){
  9. $this->connect = pg_connect($this->con_string);
  10. }
  11.  
  12. function executarSQL($sql){
  13. return pg_query($this->connect, $sql);
  14. }
  15.  
  16. function prepararString($texto){
  17. return '''.$texto.''';
  18. }
  19.  
  20.  
  21. }
  22. ?>
  23.  
  24. <?php
  25. //session_start();
  26. include ("classes/conexao.php");
  27. $postgresql=new conexao;
  28.  
  29.  
  30. if(isset($_POST['usuario'])){
  31. $usuario=$postgresql->converte($_POST['usuario']);
  32. $senha=$postgresql->converte($_POST['senha']);
  33. $sql= 'select * from usuario where usuario='.$postgresql-
  34. >prepararString($usuario).' and senha='.$postgresql->prepararString($senha);
  35.  
  36. $result = $postgresql->executarSQL($sql);
  37. if (pg_num_rows($result) > 0){
  38. $_SESSION['usuario']=$usuario;
  39. header("Location: anexos/principal.php");
  40. }else{
  41. echo "<center><font align='center' size='5' color='RED'>O NOME DE USUÁRIO E SENHA DIGITADOS SÃO INCORRETOS.</a></font></center><br>";
  42.  
  43.  
  44. }
  45. }
  46. else{
  47. header("Location: login.php");
  48. }
  49.  
  50. ?>
Add Comment
Please, Sign In to add comment