Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Testando os códigos!</title>
- </head>
- <body>
- <!--<script>
- //Função verifica campos!
- function valida(){
- if(formindex.txt_Cliente.value == "" || formindex.txt_Apelido.value == ""){
- alert("Todos os Campos devem ser preenchidos!");
- }
- }
- </script>
- -->
- <?php
- //Deixar os campos preenchidos após uma mensagem.
- $txt_Usuario = (!empty($_POST['txt_Usuario'])) ? $_POST['txt_Usuario'] : '';
- $txt_Senha = (!empty($_POST['txt_Senha'])) ? $_POST['txt_Senha'] : '';
- ?>
- <font face="Arial" size="3"><p align="center"><b>Sistemas de Atendimento</b></p></font>
- <form action="" method="post" name="formindex">
- <table border="1" cellspacing="0" cellpadding="1" align="center">
- <tr>
- <td>
- <font face="Arial" size="2"><b>Nome:</b></font>
- </td>
- <th>
- <input type="text" name="txt_Usuario" id="txt_Usuario" value="<?php echo $txt_Usuario; ?>"><br>
- </th>
- </tr>
- <tr>
- <th>
- <font face="Arial" size="2"><b>Password:</b></font>
- </th>
- <td>
- <input type="password" name="txt_Senha" id="txt_Senha" value="<?php echo $txt_Senha; ?>"><br>
- </td>
- <tr>
- <td align="right" colspan="2">
- <input type="submit" name="btm_Enviar" value="Enviar">
- <input type="reset" name="btm_Limpar" value="Limpar">
- </td>
- </tr>
- </table>
- <?php
- //Verifica dados preenchidos em campos!
- if( $_SERVER['REQUEST_METHOD']=='POST' ){
- if( $_POST['txt_Usuario'] == ""){
- printf('<p align="center"><font face="arial" size="2" color="red"><b>Digite o Nome!</b></font></p>');
- }
- else if( $_POST['txt_Senha'] == "" ){
- printf('<p align="center"><font face="arial" size="2" color="red"><b>Digite o Senha!</b></font></p>');
- }
- else
- {
- include 'conexao.php';
- $Usuario_Campo = $_POST['txt_Usuario'];
- $Senha_Campo = $_POST['txt_Senha'];
- //Recebendo informações do banco de dados.
- $sql = "SELECT Usuario, Senha FROM `usuarios` WHERE Usuario = '" . $Usuario_Campo . "'
- and Senha ='" . $Senha_Campo . "' and Tipo='administrador'";
- //Armazenado a consulta em uma variável.
- $Registro = mysql_query($sql) or die(mysql_error());
- //Verificando quantas linhas tem o registro;
- $i = mysql_num_rows($Registro) or die (mysql_error());
- if($i > 0){
- while($linha = mysql_fetch_array($Registro)){
- $Usuario = $linha['Usuario'];
- $Senha = $linha['Senha'];
- }
- }
- echo $Usuario; ?><br><?php
- echo $Usuario_Campo; ?><br><?php
- echo $Senha; ?><br><?php
- echo $Senha_Campo; ?><br><?php
- if($Usuario == $Usuario_Campo && $Senha = $Senha_Campo)
- {
- echo('<a href="Cadastro.php"><p align="center"><font face="arial" size="2" color="red"><b>Cadastro</b></font></p></a>');
- echo('<a href="Consulta.php"><p align="center"><font face="arial" size="2" color="red"><b>Consulta</b></font></p></a>');
- }
- else
- {
- echo('Dados Não Conferem!');
- }
- }
- }
- ?>
- </table>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment