daily pastebin goal
68%
SHARE
TWEET

fixed

a guest Dec 9th, 2012 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.      session_start();
  3.      function loginform() {
  4.        echo " <form action='' method='post'>
  5.              Usernane: <input type='text' name='username'/>
  6.              Password: <input type='text' name='password'/>
  7.                        <input type='submit' name='login' value='Login'/>
  8.                        </form>";
  9.  
  10.      }
  11.       function logoutform() {
  12.        echo " <form action='' method='post'>
  13.              <input type='submit' name='logout' value='Logout'/>
  14.              </form>";
  15.      }
  16.  
  17.       function login($username, $password) {
  18.         $pass=md5($password);
  19.         $conn=mysql_connect("localhost", "root", "")or die(mysql_error());
  20.         mysql_select_db("registrazione", $conn) or die (mysql_err());
  21.         $result=mysql_query("SELECT * FROM user WHERE username='$username' AND password='$pass' ") or die (mysql_err());
  22.         $count= @mysql_num_row($result);
  23.  
  24.         if ($count==1){
  25.             $_SESSION['login']=$username;
  26.             echo "Login avvenuto con successo....";
  27.         }
  28.         else {
  29.         echo "login errato. Controlla password e username...";
  30.         }
  31.      }
  32.       function logout(){
  33.         $session_destroy();
  34.       }
  35.      if (isset($_SESSION['login'])){
  36.          echo "sei loggato, puoi uscire facendo click sul logout sotto<br>";
  37.          logoutform();
  38.      }else{
  39.           echo "non sei loggato, fai i login...";
  40.        loginform();
  41.      }
  42.      if ($_POST['login']){
  43.      echo "login in corso.....";
  44.    
  45.      login($_POST['username'], $_POST['password']);
  46.      }
  47.      elseif ($_POST['logout']){
  48.      echo "stai facendo il logout....";
  49.      logout();
  50.      }
  51. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top