Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $user=false;
- $pass=false;
- if(!isset($_SESSION["username"])){
- if(isset($_POST["username"]))
- if(empty($_POST["username"]))
- echo "inserisci username </br>";
- else{
- $username=$_POST["username"];
- $user=true;
- }
- if(isset($_POST["password"]))
- if(empty($_POST["password"]))
- echo "inserisci password </br>";
- else{
- $password=$_POST["password"];
- $password=md5($password);
- $pass=true;
- }
- if($user && $pass){
- $connessione=mysql_connect("localhost","root","");
- $ris=mysql_query("use sito",$connessione);
- $ris=mysql_query("select username from utenti where username='".$username."' && password='".$password."'",$connessione);
- if(mysql_num_rows($ris)>0){
- $_SESSION['username']= $username;
- $_SESSION['password']= $password;
- header("location: homepage.php");
- }
- else
- echo "username o password non corretti";
- }
- }//fine if
- else
- header("location: homepage.php");
- if(isset($_POST["logout"])) {
- session_destroy();
- session_unset("username");
- session_unset("password");
- }
- if(isset($_POST["remove"])) {
- $connessione=mysql_connect("localhost","root","");
- $ris=mysql_query("use sito",$connessione);
- $ris=mysql_query("delete from utenti where username='".$_SESSION["username"]."'",$connessione);
- session_destroy();
- session_unset("username");
- session_unset("password");
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Login</title>
- </head>
- <body>
- <h1>Accedi</h1>
- <form action="login.php" method="POST">
- Inserire username:
- <input type="text" name="username"></br></br>
- Inserire password:
- <input type="password" name="password"></br></br>
- <input type="submit" value="Login">
- </form>
- </br>
- <a href="registrati.php">Non sei registrato? Registrati</a>
- </body>
- </html>
Add Comment
Please, Sign In to add comment