<?php
// Parametri di connessione al database
$servername = "";
$username = "";
$password = "";
$dbname = "";
// Connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
// Verifica della connessione
if ($conn->connect_error) {
die("Connessione fallita: " . $conn->connect_error);
}
// Controllo delle credenziali di accesso
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST["username"];
$password = $_POST["password"];
// Esegue una query per verificare le credenziali
$sql = "SELECT * FROM utenti WHERE username = '$username' AND password = '$password'";
$result = $conn->sqli($sql);
if ($result->num_rows == 1) {
// Credenziali corrette, reindirizza alla pagina desiderata
header("Location: google.com");
exit();
} else {
// Credenziali errate, mostra un messaggio di errore
$error_message = "Credenziali non valide. Riprova.";
}
}
// Chiusura della connessione
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<style>
/* Stili CSS */
body {
background-color: #f1f1f1;
font-family: Arial, sans-serif;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 40px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-top: 100px;
}
.container h2 {
text-align: center;
color: #333333;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 5px;
color: #666666;
font-weight: bold;
}
.form-group input {
width: 100%;
padding: 10px;
border: 1px solid #cccccc;
border-radius: 3px;
}
.form-group input[type="submit"] {
background-color: #339966;
color: #ffffff;
cursor: pointer;
}
.form-group input[type="submit"]:hover {
background-color: #26734d;
}
.error-message {
color: red;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h2>Login</h2>
<form action="process-login.php" method="POST">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<input type="submit" value="Login">
</div>
</form>
<?php
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<style>
/* Stili CSS */
body {
background-color: #f1f1f1;
font-family: Arial, sans-serif;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 40px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-top: 100px;
}
.container h2 {
text-align: center;
color: #333333;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 5px;
color: #666666;
font-weight: bold;
}
.form-group input {
width: 100%;
padding: 10px;
border: 1px solid #cccccc;
border-radius: 3px;
}
.form-group input[type="submit"] {
background-color: #339966;
color: #ffffff;
cursor: pointer;
}
.form-group input[type="submit"]:hover {
background-color: #26734d;
}
.error-message {
color: red;
margin-top: 10px;
}
</style>
</head>
</html>