0% found this document useful (0 votes)
6 views2 pages

Index

This document is a PHP script for a login system that checks user credentials against a database. It includes form validation to ensure that both username and password are provided, and it handles successful and failed login attempts. The HTML portion creates a styled login interface for users to input their credentials.

Uploaded by

glservidor8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Index

This document is a PHP script for a login system that checks user credentials against a database. It includes form validation to ensure that both username and password are provided, and it handles successful and failed login attempts. The HTML portion creates a styled login interface for users to input their credentials.

Uploaded by

glservidor8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?

php
include('conexao.php');
if(isset($_POST['usuario']) && isset($_POST['senha'])) {

if(strlen($_POST['usuario']) == 0) {
echo "Usuario não informado";
} else if(strlen($_POST['senha']) == 0) {
echo "Preencha sua senha";
} else {

$usuario = $mysqli->real_escape_string($_POST['usuario']);
$senha = $mysqli->real_escape_string($_POST['senha']);
$sql_code = "SELECT * FROM usuarios WHERE usuario = '$usuario' AND senha =
'$senha'";
$sql_query = $mysqli->query($sql_code) or die("Falha na execução do código
SQL: " . $mysqli->error);
$quantidade = $sql_query->num_rows;

if($quantidade == 1) {
$usuario = $sql_query->fetch_assoc();
if(!isset($_SESSION)) {
session_start();
}
$_SESSION['id'] = $usuario['id'];
$_SESSION['nome'] = $usuario['nome'];
header("Location: painel.php");
} else {
echo "Falha ao logar! E-mail ou senha incorretos";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<style>
body{
font-family: Arial, Helvetica, sans-serif;
background-image: linear-gradient(45deg, green, orange);
}
.tela-login{
background-color: rgba(0, 0, 0, 0.8);
position:absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
padding: 60px;
border-radius: 20px;
color: whitesmoke;
}
input{
padding: 16px;
border: none;
outline: none;
font-size: 18px;
}
button{
background-color: dodgerblue;
border: none;
outline: none;
padding: 16px;
width: 100%;
border-radius: 12px;
color: white;
font-size: 20px;
}
button:hover{
background-color: deepskyblue;
cursor: pointer;
}

</style>
</head>
<body>
<div class="tela-login">
<h1>Login</h1>
<form action="" method="POST">
<br>
<input type="text" name="usuario" placeholder="Usuário">
<br><br>
<input type="password" name="senha" placeholder="Senha">
<br><br>
<button type="submit">Entrar</button>
</form>
</div>
</body>
</html>

You might also like