Jump to content
Fórum Script Brasil
  • 0

Select em duas tabelas diferentes com campos diferentes



Amigos. Não sei se serei claro mas vamos lá.

Tenho duas tabelas. ALUNOS_FUNDAMENTAL e ALUNOS_MEDIO, os únicos campos iguais são: ID, NOME, LOGIN, SENHA E NIVEL.

Não quero juntar nada. Somente listar as duas. Isso usando o mesmo post do formulário de login.

Este é meu código funcionando perfeitamente com a tabela ALUNOS_FUNDAMENTAL.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include_once "admin/config.php";

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sala On line - Login</title>
<link href="admin/css/style.css" rel="stylesheet" type="text/css" />

         $login = $_POST['login'];
         $senha = $_POST['senha'];
    $query = mysql_query("SELECT * FROM alunos_fundamental WHERE login = '$login' AND senha = '$senha'");
    $conta = mysql_num_rows($query);
        if($conta == '0'){
            header ("location:erro.php");
            while($res = mysql_fetch_array($query)){
                $id = $res['Id'];
                $login = $res['login'];
                $senha = $res['senha'];
                $nome = $res['nome'];
                $nivel = $res['nivel'];
                $turma = $res['turma'];
                $_SESSION['Id'] = $id;
                $_SESSION['login'] = $login;
                $_SESSION['senha'] = $senha;
                $_SESSION['nome'] = $nome;
                $_SESSION['nivel'] = $nivel;
                $_SESSION['turma'] = $turma;
                if($nivel == 'admin'){
                    header ("location:admin/index.php");
                }else if($nivel == '6ano'){
                    header ("location:user/indexaluno.php");

                }else if($nivel == '7ano'){
                    header ("location:user/indexaluno.php");

                }else if($nivel == '8ano'){
                    header ("location:user/indexaluno.php");

                }else if($nivel == '9ano'){
                    header ("location:user/indexaluno.php");
                }else if($nivel == 'medio'){
                    header ("location:user/indexaluno.php");



        <form action="" method="post" enctype="multipart/form-data">
                <input type="text" name="login" />
                <input type="password" name="senha" />
             <br /><br />

           <input type="hidden" name="acao"  value="login"/> 
          <input type="submit" value="Entrar" class="btn-cad" />


Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

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

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.

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...