Jump to content
Fórum Script Brasil
  • 0

Erro De Lógica


Eric Freitas
 Share

Question

bom pessoal... se lerem meu código verão q num é dificil o que eu quero fazer..

mas to com um probleminha na lógica do php.. se alguém puder me ajudar a achar o erro agradeço..

INDEX.PHP
<?php
    session_start();
    $_SESSION['username'] = $_POST['username'];
    $_SESSION['passwd'] = $_POST['senha'];
    require_once'funcoesUser.php';
    echo'<link rel="stylesheet" type="text/css" href="estilo.css" />';
    if(empty($_GET['ins'])){
        verUser($_SESSION['username'],$_SESSION['passwd']);
    }elseif(!empty($_GET['ins'])){
        $_ins = $_GET['ins'];
        //-----------------------------------------------------------------------------------------------------
        switch ($_ins){
        case 1:
            echo'<div class="meio">';        
            echo'<form id="form1" name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'?ins=2">';
            echo'<table width="150" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                       <td colspan="3"><div align="center"><strong>Registrar Usu&aacute;rio </strong></div></td>    
                 </tr>    
                    <tr>
                      <td>Username:</td>
                      <td>&nbsp;</td>
                      <td><input name="username" type="text" id="username" size="15" maxlength="15" /></td>
                </tr>
                <tr>
                      <td>Password:</td>
                      <td>&nbsp;</td>
                      <td><input name="senha" type="password" id="senha" size="15" maxlength="15" /></td>
                </tr>
                <tr>
                      <td colspan="3"><div align="center">
                           <input name="Enviar" type="submit" id="Enviar" value="Enviar" />
                           <input name="Resetar" type="reset" id="Resetar" value="Limpar" />
                      </div></td>
                </tr>
                  </table>
                </form>';
            echo'</div>';
            break;
        case 2:
                echo'<div class="meio">';
                $_user = $_POST['username'];
                $_pass = $_POST['senha'];
                if(strlen($_pass)>15 ||strlen($_pass)<8){
                    echo'Sua senha deve conter mais que <font color="red">8</font> e menos q <font color="red">15</font> caracteres';
                    echo'<META HTTP-EQUIV="Refresh" CONTENT="5;URL=?ins=1">';
                }
                require_once'conectaBanco.php';
                $_sql = mysql_query("INSERT INTO tp_usuario (username,passwd,permissao) VALUES ('$_user','$_pass','0')") or die('Erro de query');
                if($_sql){
                    echo'Dados incluidos com sucesso!';
                    $_SESSION['username'] = $_POST['username'];
                    $_SESSION['passwd'] = $_POST['senha'];
                    verUser($_POST['usename'],$_POST['senha']);
                    echo'<META HTTP-EQUIV="Refresh" CONTENT="5;URL=?acao=0">';
                }
                echo'</div>';
                break;
                default:
                    echo'div class="meio">';
                    echo'Operação inválida';
                    echo'</div>';
                    break;
        }    
    }elseif(!empty($_GET['acao'])){
        
    //------------------------------------------------------------------------------------
        switch($_GET['acao']){
            case 0:
            echo'<div class="tabela">';
                echo'<h1>Operador de tramitações</h1>';
                echo'</div>';
                break;

            case 1:
                if(verUser($_POST['username'],$_POST['senha'])==true){
                    
                }else{
                    echo'div class="meio">';
                    echo'Usuário e/ou senha inválidos';
                    echo'</div>';
                }
                break;
            default:
                echo'<div class="meio">';
                echo'Operação inválida';
                echo'</div>';
                break;
            
        }
    }
?>
FUNCOESUSER.PHP
<?php
    function verUser($_login,$_senha){
        require_once'conectaBanco.php';
        $_sqlVerifica = mysql_query("SELECT * FROM tp_usuario") or die('Erro na query');
        $_sql = mysql_query("SELECT * FROM tp_usuario where username = '$_login' and passwd = '$_senha'") or die('Erro na query');
        $_linhas = mysql_num_rows($_sqlVerifica);
        if($_linhas==0){
            echo'<META HTTP-EQUIV="Refresh" CONTENT="1;URL=?ins=1">';
        }elseif(!$_sql){
            return false;
        }else{
            return true;
            echo'<META HTTP-EQUIV="Refresh" CONTENT="1;URL=?acao=1">';
        }
        }
    
?>

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.2k
    • Total Posts
      647.5k
×
×
  • Create New...