Bootstrap modal login

0

I created a login button in the navbar of the site, when the user clicks open a modal with the login form. In the navbar php file I am calling the file "validaLogin.php" to check the user data and store it in a session variable, but when I submit another form in another page, it submits the two forms, for example, in the page contact, has a form, and when clicking on send in form, it submits in both, however as in the page there is no login form variables gives the following error:

  

"Notice: Undefined index: login in   C: \ xampp \ htdocs \ ClinicaMedica \ php \ validalogin.php on line 13

     

Notice: Undefined index: password in   C: \ xampp \ htdocs \ ClinicaMedica \ php \ validalogin.php on line 14 "

validaLogin.php:

<?php
session_start();
include("conexaoMysql.php");

function filtraEntradaV($dado){
    $dado = trim($dado);
    $dado = stripslashes($dado);
    $dado = htmlspecialchars($dado);
    return $dado;
};  

if($_SERVER["REQUEST_METHOD"] == 'POST'){
    $login = filtraEntradaV($_POST["login"]);
    $senha = filtraEntradaV($_POST["senha"]);


    $sql = "SELECT Login FROM clinicamedica.usuario where Login = '$login' and Senha = '$senha' ";
    $resultado = $conn->query($sql);

    if($resultado->num_rows <= 0){
        echo "<script>alert('Dados incorretos')</script>";}
    else
        $_SESSION["login"] = $login;

}


?>

contact page:

<?php
include("conexaoMysql.php");

function filtraEntradaC($dado){
    $dado = trim($dado);
    $dado = stripslashes($dado);
    $dado = htmlspecialchars($dado);
    return $dado;
}   

if($_SERVER["REQUEST_METHOD"] == 'POST'){
    $msgErro = '';
    $nome = $email = $motivo = $mensagem = "";


    $nome = filtraEntradaC($_POST["nome"]);
    $email = filtraEntradaC($_POST["email"]);
    $motivo = filtraEntradaC($_POST["motivo"]);
    $mensagem = filtraEntradaC($_POST["mensagem"]);

    try{


        $sql = "
            INSERT INTO clinicamedica.contato(Id, Nome, Email, Motivo, Mensagem)
            values (null, ? , ? , ? , ?);
        ";

        $stmt = $conn->prepare($sql);

        $stmt->bind_param("ssss", $nome , $email , $motivo , $mensagem);

        if (! $stmt->execute())
            throw new Exception("Erro ao realizar o contato: " . $conn->error);


        $formProcSucesso = true;
        } catch (Exception $e){
            $msgErro = $e->getMessage();
        }
}
?>

How can I resolve?

    
asked by anonymous 10.11.2017 / 14:04

0 answers