Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class conexao{
- var $connect;
- var $con_string = "host=localhost/TCC port=5432 dbname=TCC user=postgres password=123456";
- function conexao(){
- $this->connect = pg_connect($this->con_string);
- }
- function executarSQL($sql){
- return pg_query($this->connect, $sql);
- }
- function prepararString($texto){
- return '''.$texto.''';
- }
- }
- ?>
- <?php
- //session_start();
- include ("classes/conexao.php");
- $postgresql=new conexao;
- if(isset($_POST['usuario'])){
- $usuario=$postgresql->converte($_POST['usuario']);
- $senha=$postgresql->converte($_POST['senha']);
- $sql= 'select * from usuario where usuario='.$postgresql-
- >prepararString($usuario).' and senha='.$postgresql->prepararString($senha);
- $result = $postgresql->executarSQL($sql);
- if (pg_num_rows($result) > 0){
- $_SESSION['usuario']=$usuario;
- header("Location: anexos/principal.php");
- }else{
- echo "<center><font align='center' size='5' color='RED'>O NOME DE USUÁRIO E SENHA DIGITADOS SÃO INCORRETOS.</a></font></center><br>";
- }
- }
- else{
- header("Location: login.php");
- }
- ?>
Add Comment
Please, Sign In to add comment