Execute include within if

0

Hello

I need to add include inside a if function but at the time of execution it does not read the added include. Can someone give me a hint where the error is.

Menu content.html

<div id='menutopo'>
  <div id= 'menu1'>
    <button id='dropbtn1'>Cadastro</button>
        <div id='dropdown-content1'>
            <a href='cadastrocliente.html'>Clientes</a>
            <a href='cadastroprodutos.php'>Produtos</a>
        </div>
  </div>
  <div id='menu2'>  
    <button id='dropbtn2'>Moveis</button>
        <div id='dropdown-content2'>
            <a href='fichademoveis.html'>Criar Ficha</a>
            <a href='#'>Consulta de Ficha</a>
        </div>
</div>
   <div id= 'menu3'>
     <button id='dropbtn3'>Consulta</button>
        <div id='dropdown-content3'>
            <a href='consultadecliente.php'>Clientes</a>
        </div>
  </div>
</div>

The php file that checks and confirms the variables will execute an html.

<?php
  include "in/conecta.inc";

?>

<?php


if($cont==1 && $cont2=1){
    echo "<!DOCTYPE html>

  <html lang='pt-br'>
  <head>
   <meta charset='UTF-8'/>
  <meta name='description' content='Bem vindo ao Bsis vendas'>
  <meta name='viewport' content='width=device-width, user-scalable=no,      initial-scale=1.0,maximum-scale=1, minimun-scale=1'>
   <link rel='icon' type='image/png' href='imagens/favicon.png'>
    <link rel='stylesheet' type='text/css' href='css/estilo.css'>
   <link rel='stylesheet' type='text/css' href='css/login.css'>



  </head>
  <body>
  <header>


  <?php

     include ('in/menu.inc');?>

   </header>
  <div id='bordacabecalho'></div>

  <footer>
   <nav id='menurodape'>
      <ul>
          <li><a href='manual.html'>Manual</a></li>
      </ul>
      </nav>


    </footer>
    </body>
     </html>";
            }
     else{

      echo "<!DOCTYPE html>

     <html lang='pt-br'>
     <head>
      <meta charset='UTF-8'/>
     <meta name='description' content='Bem vindo ao Bsis vendas'>
     <meta name='viewport' content='width=device-width, user-scalable=no, init ial-scale=1.0,maximum-scale=1, minimun-scale=1'>
     <link rel='icon' type='image/png' href='imagens/favicon.png'>
      <link rel='stylesheet' type='text/css' href='css/estilo.css'>
     <link rel='stylesheet' type='text/css' href='css/login.css'>


     <script src='javascript/login.js'>

     </script>
     </head>
     <body>
     <header>
      <a href='index.html'><img id= 'logo' src='imagens/baixinhologo.png'></a>
    </header>
    <div id='bordacabecalho'></div>

     <form id='login' action= 'login.php' method='post'>
   <p>Login:<input type='text' name='login' placeholder= 'login'/></p>
   <p>Senha:<input type='password' name='senha' placeholder='senha'/></p>

   Senha incorreta tente novamente

   <input type='submit'id='botao' name='botaoo' value='Entrar'/>

  </form>
  <footer>
  <nav id='menurodape'>
    <ul>
        <li><a href='manual.html'>Manual</a></li>
    </ul>
</nav>


 </footer>
  </body>
 </html>";}
 ?>
    
asked by anonymous 19.05.2016 / 03:42

2 answers

2

Edition:

<?php
include "in/conecta.inc";

$doc = $_POST['login'];
$senha = $_POST['senha'];
$try = mysqli_query($conn, "select login from usuarios where login='$doc' and senha='$senha'");
$cont = mysqli_num_rows($try);
$tru = mysqli_query($conn, "select senha from usuarios where senha='$senha' and login='$doc'");
$cont2 = mysqli_num_rows($tru);

if ($cont == 1 && $cont2 = 1) {
    ?>
    <!DOCTYPE html>

    <html lang='pt-br'>
        <head>
            <meta charset='UTF-8'/>
            <meta name='description' content='Bem vindo ao Bsis vendas'>
            <meta name='viewport' content='width=device-width, user-scalable=no, initial-scale=1.0,maximum-scale=1, minimun-scale=1'>
            <link rel='icon' type='image/png' href='imagens/favicon.png'>
            <link rel='stylesheet' type='text/css' href='css/estilo.css'>
            <link rel='stylesheet' type='text/css' href='css/login.css'>



        </head>
        <body>
            <header>


                <?php
                include 'in/menu.inc';
                ?>

            </header>
            <div id='bordacabecalho'></div>

            <footer>
                <nav id='menurodape'>
                    <ul>
                        <li><a href='manual.html'>Manual</a></li>
                    </ul>
                </nav>


            </footer>
        </body>
    </html>
    <?php
} else {
    ?>
    <!DOCTYPE html>

    <html lang='pt-br'>
        <head>
            <meta charset='UTF-8'/>
            <meta name='description' content='Bem vindo ao Bsis vendas'>
            <meta name='viewport' content='width=device-width, user-scalable=no, init ial-scale=1.0,maximum-scale=1, minimun-scale=1'>
            <link rel='icon' type='image/png' href='imagens/favicon.png'>
            <link rel='stylesheet' type='text/css' href='css/estilo.css'>
            <link rel='stylesheet' type='text/css' href='css/login.css'>


            <script src='javascript/login.js'>

            </script>
        </head>
        <body>
            <header>
                <a href='index.html'><img id= 'logo' src='imagens/baixinhologo.png'></a>
            </header>
            <div id='bordacabecalho'></div>

            <form id='login' action= 'login.php' method='post'>
                <p>Login:<input type='text' name='login' placeholder= 'login'/></p>
                <p>Senha:<input type='password' name='senha' placeholder='senha'/></p>

                Senha incorreta tente novamente

                <input type='submit'id='botao' name='botaoo' value='Entrar'/>

            </form>
            <footer>
                <nav id='menurodape'>
                    <ul>
                        <li><a href='manual.html'>Manual</a></li>
                    </ul>
                </nav>


            </footer>
        </body>
    </html>
    <?php
}

You simply did not close if and did not close echo properly:

<?php
if($cont==1 && $cont2=1){
    echo "<!DOCTYPE html>

    <html lang='pt-br'>
    <head>
    </head>
    <body>
   <header>

    <?php

    include('in/menu.html');

     ?>";
}

Another way is form is:

<?php
if($cont==1 && $cont2=1){
?>
    <!DOCTYPE html>

    <html lang='pt-br'>
    <head>
    </head>
    <body>
   <header>

    <?php

    include('in/menu.html');
}
    
19.05.2016 / 03:54
0

After some reading I found the reason for my mistake, where Eduardo Almeida's help was extremely useful giving the ways to understand the code. Read the instructions passed by him

    
20.05.2016 / 02:52