php appears on my main page

Asked

Viewed 62 times

0

I’m making my front page with my login, but I don’t know why PHP appears that I did. What I wanted to do was hide PHP.

My code:

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
        <link  rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" >
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

        <link  rel="stylesheet" href="estilos.css" >

    </head>

<body>

<a href="https://www.instagram.com/restaurantesintra/" target="_black" class="icons">  <!--- target="_black" ->faz com  que abra outra pagina sem remover a quinta --->
<img src= "instagramicon.jpg" > <font size="2,5"> @RestauranteSintra </font> 
</a>

<a href="https://www.facebook.com/Restaurante-Sintra-421444064978267/?modal=admin_todo_tour" target="_black">
<img src= "facebookicon.png"> <font size="2,5"> @RestauranteSintra </font>
</a>

<a href="https://twitter.com/rest_sintra" target="_black">
<img src= "twittericon.png"> <font size="2,5"> @Rest_Sintra </font>
</a>

<a href="quintafr.html">
<img src= "franca.png"width="17px" height="16px" style=" margin-left:4800%;">
</a>

<a href="quintaeng.html" >
<img src= "inglaterra.png"width="17px" height="16px" style=" margin-left:4780%;">
</a>

<a href="quinta.html" >
<img src= "portugal.jpg"width="17px" height="16px" style=" margin-left:4750%;">
</a>

<div class="frente">    

    <a href="quinta.html">
    <img src="33.png" width="170" height="90" hspace="657">

    </a>

<nav class="menu">
    <ul>
        <div>
        <li><a href="Restaurante.html">Restaurante </a></li>
        <li><a href="ementa.html">Menu</a></li>
        <li><a href="Reserva.html">Reserva</a></li>
        <li><a href="domicilio.html">Domicílio</a></li>
        <li><a href="Contacto.html">Contacto</a></li>

        </div>
    </ul>
    <br><br>



                <button class="login"  onclick="document.getElementById('id01').style.display='block'" style="border:2px solid black; width:auto; border-radius:10%;" ><i class="fa fa-user">Iniciar Sessão</i></button>


    <div id="id01" class="modal">

                <form class="modal-content animate" action="indexlogin.php" method="post" >


        <div class="container">
                        <label><b>Email</b></label>
                            <input  id="field"type="text" name="email"style="border:1px solid black; width:auto;" placeholder="Email" required>

                        <label><b>Palavra-Passe</b></label>
                            <input  id="field" type="password" name="password"style="border:1px solid black; width:auto;" placeholder="Palavra-Passe"required>

                        <button  id="field" type="submit"  name="login" style="border:1px solid black; width:200px;" >Entrar</button>
        </div>



                <div class="container" style="background-color: #adad85">
                        <button type="button" onclick="document.getElementById('id01').style.display='none'" style=" border:1px solid black; width:auto; border-radius:10%;" class="cancelarbutao">Cancelar</button>
                </div>

                </form>
    </div>      

    <button class="carrinhodecompras" style="border:2px solid black;  border-radius:10%;" ><i class="fa fa-shopping-cart">Compras</i></button>

    </div>
</nav>  


<center>                                                                        <!---- slideshow de imagens--->
        <div class="w3-content w3-row">
           <div class="w3-col w3-left w3-container" ></div>
            <div class="w3-col w3-right w3-container"> </div>
        <div class="w3-col s4 imagens1">
        <br><br>
        <img class="mySlides1 w3-animate-fading" src="1a.jpg" height="312" width="237">
        <img class="mySlides1 w3-animate-fading" src="comida1.png" height="312" width="237">
        <img class="mySlides1 w3-animate-fading" src="cozinha1.jpg" height="312" width="237">       
        </div>

            <div class="w3-col s4 imagens2">
        <br><br>
        <img class="mySlides2 w3-animate-fading" src="1b.jpg" height="312" width="237">
        <img class="mySlides2 w3-animate-fading" src="comida2.png" height="312" width="237">
        <img class="mySlides2 w3-animate-fading" src="cozinha2.jpg" height="312" width="237">


            </div>


            <div class="w3-col s4 imagens3">
            <br><br>
        <img class="mySlides3 w3-animate-fading" src="1c.jpg" width="237px" height="312px">
        <img class="mySlides3 w3-animate-fading" src="comida3.png" width="237px" height="312px">
        <img class="mySlides3 w3-animate-fading" src="cozinha3.png" width="237px" height="312px">

            </div>

                   <div class="w3-col s4 imagens4">
                   <br><br>
        <img class="mySlides4 w3-animate-fading" src="1d.jpg" width="237px" height="312px" >
        <img class="mySlides4 w3-animate-fading" src="comida4.png" width="237px" height="312px">
        <img class="mySlides4 w3-animate-fading" src="cozinha4.jpg" width="237px" height="312px">
        </div>
</center>


        <br><br><br><br><br><br><br><br>
           </div>
<br><br><br><br><br><br><br><br><br><br><br>    <br><br><br><br><br><br><br><br>                                        <!---- Inicio da barra na parte final da pagina--->
<div class="frente">
<font color="white" size="2">
  &nbsp;
  Restaurante Sintra.EM529,Silves, Faro.282 xxx [email protected]
  <br>

  <br>
</font>
</div>  

<script>

var modal = document.getElementById('id01');

window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
</script>                                                  
  <script>
    var myIndex1 = 0;
            var myIndex2 = 0;
            var myIndex3 = 0;
            var myIndex4 = 0;   
            carousel();

            function carousel() {
                    var i;
                    var x1 = document.getElementsByClassName("mySlides1");
                    var x2 = document.getElementsByClassName("mySlides2");
                    var x3 = document.getElementsByClassName("mySlides3");
                    var x4 = document.getElementsByClassName("mySlides4");  

                   for (i = 0; i < x1.length; i++) {
                        x1[i].style.display = "none";
                    }
                    for (i = 0; i < x2.length; i++) {
                        x2[i].style.display = "none";
                    }
                    for (i = 0; i < x3.length; i++) {
                        x3[i].style.display = "none";
                    }

                    for (i = 0; i < x4.length; i++) {
                        x4[i].style.display = "none";
                    }       


                    myIndex1++;
                    if (myIndex1 > x1.length) {myIndex1 = 1}
                    x1[myIndex1-1].style.display = "block";
                    myIndex2++;
                    if (myIndex2 > x2.length) {myIndex2 = 1}
                    x2[myIndex2-1].style.display = "block";
                    myIndex3++;
                    if (myIndex3 > x3.length) {myIndex3 = 1}
                    x3[myIndex3-1].style.display = "block";
                    myIndex4++;
                    if (myIndex4 > x4.length) {myIndex4 = 1}
                    x4[myIndex4-1].style.display = "block";
                    setTimeout(carousel, 10000);
            }
        </script>

        <br><br>

    </body>
</html>

    <?php
    //LOGIN
    $connect = mysql_connect("localhost", "a23144", "*****") or die("Erro");                            // faz a conecxão a base de dados
    $db = mysql_select_db("a23144",$connect) or die("Erro");                                            // selecionar a base de dados

    if(isset($_POST["login"])) {                                                                        // vai verificar se existe
    $email = md5($_POST ["email"]);                                                                     // md5 é a segurança basica. o email fica encrpitado ou se ja eu n vou  saber o email  dele
    $password = md5($_POST["password"]);                                                                // o email e a pass são as variaveis
    $verificar = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'");      // verifica a coluna da base de dados
    if (mysql_num_rows($verificar)<=0){                                                             // faz a contagem dos dados que recebeu.                                    
        echo "<h3> Dados de login incorretos!</h3>";                                                    // se não  econtrar os dados da erro
    }else{
        setcookie("login",$email);
        header("Location: entrou.php");                                                                     // se econtrar os daods vai para o arquivo entrou.php
    }
    }

    //REGISTAR
    if(isset($_POST["registar"])) {                                                                     // vai verificar se existe
    $nome = $_POST["nome"]; 
    $email = md5($_POST ["email_registar"]);                                                                    // md5 é a segurança basica. o email fica encrpitado ou se ja eu n vou  saber o email  dele
    $password = md5($_POST["password_registar"]);                                                               // o email e a pass são as variaveis
    $password_rep = md5($_POST["password_rep"]);    
    $verificar = mysql_query("SELECT * FROM users WHERE email='$email'");                                   // verifica a coluna da base de dados

    if (mysql_num_rows($verificar)>0){                                                                          // faz a contagem dos dados que recebeu.                                    
        echo "<h3>Esta conta já está registada</h3>";                                                   // se não  econtrar os dados da erro

    }elseif ($_POST["email_registar"]==""){                                                             // se não o  email  n tiver inserido na texto box diz "tem q inserir email"
        echo "<h3>Tem que inserir um email!</h3>";                                                                      


    }elseif ($_POST["password_registar"]==""){
        echo "<h3>Tem que inserir uma Palavra-passe!</h3>";                                                                     


    }elseif ($_POST["password_registar"]=!$_POST["password_rep"]){
        echo "<h3>As palavra-passe não coincidem!</h3>";                                                                        


    }elseif ($nome==""){
        echo "<h3>Escreva o seu nome!</h3>";                                                                        

    }else{                                                                                                      // apos ter inserido os daddos todos corretamente ira receber a mensagem conta resgistada com  .....
        $insert = mysql_query("INSERT INTO users (nome,email,password) VALUES('$nome','$email','$password')");
        echo"<h3> Conta registada com sucesso. Inicie sessão!</h3>";
    }
} 
    ?>
  • 5

    You are running your page on a PHP server?

  • 1

    Sintra puts your code on some Server that has PHP, or on a local server type Xamp, Wamp, Vertrigo etc that has PHP and test your .php. The document extension must be . php and not . html

  • Mmm ok I’ll modify and see how it looks. brg by help.

1 answer

2

Sintra, it’s all right?

1 - Install a php server locally. I recommend Xampp, download here link

2 - After the installation, go to the htdocs folder in the xampp installation location. By default the shaman will be installed c:\xampp\htdocs (If you have changed the installation location, and only go in the folder where you installed).

3 - Within htdocs, create a folder with your project name and then put your php file inside it.

4 - Access the url http://localhost/meu-projeto and see if your problem has been solved.

Obs: Your files have to have the . php extension to be interpreted by the server.

Any questions left? I hope I helped, hug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.