Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Area Riservata | Autenticati</title>
- <link rel="stylesheet" href="css/style2.css">
- </head>
- <body>
- <?php
- session_start();
- function Open($dbname) {
- $con = new mysqli("127.0.0.1","root","",$dbname);
- if ($con->connect_errno) {
- echo "<h2>".$con->connect_error."</h2>";
- exit();
- }
- else
- return $con;
- }
- function Query($con,$sql) {
- $res = $con->query($sql);
- if (!$res)
- echo "<h2>".$con->error."</h2>";
- return $res;
- }
- function Close($con) {
- $con->close();
- }
- if ($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $mysql = Open("catdb");
- $sql = "SELECT ID_Tecnico, Nome, Cognome
- FROM tecnico
- WHERE Username= '$username' && Password='$password'";
- $rs = Query($mysql, $sql);
- Close($mysql);
- if ($rs->num_rows == 1) {
- $obj = $rs->fetch_object();
- $_SESSION['id_tecnico'] = $obj->Id_Tecnico;
- $_SESSION['nome'] = $obj->Nome;
- $_SESSION['cognome'] = $obj->Cognome;
- header("Location: areariservata.php");
- }
- else {
- echo "<div class='container'>
- <div class='login'>
- <h1 class='login-heading'>
- <strong>Dati errati!</strong> Torna indietro.</h1>
- <button class='btn btn--right' onclick='history.back()'> Indietro </button>
- </div>
- </div>";
- }
- } else
- echo "
- <div class='container'>
- <div class='login'>
- <h1 class='login-heading'>
- <strong>Benvenuto.</strong> Autenticati.</h1>
- <form method='post' action='" . $_SERVER['PHP_SELF'] ."'>
- <input type='text' name='username' placeholder='Username' required='required' class='input-txt' />
- <input type='password' name='password' placeholder='Password' required='required' class='input-txt' />
- <button type='submit' class='btn btn--right'>Entra</button>
- </div>
- </form>
- </div>
- </div>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement