Guest User

Untitled

a guest
Jul 17th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.23 KB | None | 0 0
  1. <html>
  2.         <head>
  3.             <title>Testando os códigos!</title>
  4.         </head>
  5.         <body>
  6.      
  7.             <!--<script>               
  8.             //Função verifica campos!
  9.             function valida(){
  10.            
  11.                 if(formindex.txt_Cliente.value == "" || formindex.txt_Apelido.value == ""){
  12.                     alert("Todos os Campos devem ser preenchidos!");
  13.                 }              
  14.             }  
  15.             </script>
  16.             -->
  17.            
  18.             <?php
  19.                 //Deixar os campos preenchidos após uma mensagem.
  20.                 $txt_Usuario = (!empty($_POST['txt_Usuario'])) ? $_POST['txt_Usuario'] : '';
  21.                 $txt_Senha = (!empty($_POST['txt_Senha'])) ? $_POST['txt_Senha'] : '';
  22.             ?>
  23.            
  24.             <font face="Arial" size="3"><p align="center"><b>Sistemas de Atendimento</b></p></font>
  25.            
  26.             <form action="" method="post" name="formindex">        
  27.             <table border="1" cellspacing="0" cellpadding="1" align="center">
  28.                 <tr>
  29.                     <td>
  30.                        <font face="Arial" size="2"><b>Nome:</b></font>
  31.                     </td>
  32.                     <th>
  33.                        <input type="text" name="txt_Usuario" id="txt_Usuario" value="<?php echo $txt_Usuario; ?>"><br>
  34.                     </th>
  35.                 </tr>
  36.                 <tr>
  37.                     <th>
  38.                        <font face="Arial" size="2"><b>Password:</b></font>
  39.                     </th>
  40.                     <td>
  41.                         <input type="password" name="txt_Senha" id="txt_Senha" value="<?php echo $txt_Senha; ?>"><br>
  42.                     </td>
  43.                 <tr>
  44.                     <td align="right" colspan="2">
  45.                         <input type="submit" name="btm_Enviar" value="Enviar">
  46.                         <input type="reset" name="btm_Limpar" value="Limpar">  
  47.                     </td>
  48.                    
  49.                 </tr>
  50.             </table>
  51.  
  52.             <?php
  53.             //Verifica dados preenchidos em campos!
  54.             if( $_SERVER['REQUEST_METHOD']=='POST' ){
  55.                 if( $_POST['txt_Usuario'] == ""){
  56.                     printf('<p align="center"><font face="arial" size="2" color="red"><b>Digite o Nome!</b></font></p>');
  57.             }
  58.             else if( $_POST['txt_Senha'] == "" ){
  59.                     printf('<p align="center"><font face="arial" size="2" color="red"><b>Digite o Senha!</b></font></p>');
  60.             }
  61.             else
  62.                 {
  63.                    
  64.                     include 'conexao.php';
  65.                    
  66.                     $Usuario_Campo = $_POST['txt_Usuario'];
  67.                     $Senha_Campo = $_POST['txt_Senha'];
  68.                    
  69.                    
  70.                
  71.                     //Recebendo informações do banco de dados.
  72.                     $sql = "SELECT Usuario, Senha FROM `usuarios` WHERE Usuario = '" . $Usuario_Campo . "'
  73.                     and Senha ='" . $Senha_Campo . "' and Tipo='administrador'";
  74.                                        
  75.                     //Armazenado a consulta em uma variável.
  76.                     $Registro = mysql_query($sql) or die(mysql_error());
  77.                    
  78.                     //Verificando quantas linhas tem o registro;
  79.                     $i = mysql_num_rows($Registro) or die (mysql_error());
  80.                    
  81.                     if($i > 0){
  82.                         while($linha = mysql_fetch_array($Registro)){
  83.                             $Usuario = $linha['Usuario'];
  84.                             $Senha = $linha['Senha'];
  85.                         }
  86.                     }
  87.                    
  88.                     echo $Usuario; ?><br><?php
  89.                     echo $Usuario_Campo; ?><br><?php
  90.                     echo $Senha; ?><br><?php
  91.                     echo $Senha_Campo; ?><br><?php
  92.                    
  93.                    
  94.                     if($Usuario == $Usuario_Campo && $Senha = $Senha_Campo)
  95.                     {
  96.                         echo('<a href="Cadastro.php"><p align="center"><font face="arial" size="2" color="red"><b>Cadastro</b></font></p></a>');
  97.                         echo('<a href="Consulta.php"><p align="center"><font face="arial" size="2" color="red"><b>Consulta</b></font></p></a>');
  98.                     }
  99.                     else
  100.                     {
  101.                         echo('Dados Não Conferem!');
  102.                     }
  103.                 }
  104.                    
  105.             }
  106.             ?>
  107.             </table>
  108.             </form>
  109.       </body>
  110. </html>
Add Comment
Please, Sign In to add comment