SHARE
TWEET

Untitled

a guest Oct 4th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $host="localhost"; // Hostname
  4. $username="root"; // Mysql username
  5. $password=""; // Mysql password
  6. $db_name="lpw"; //Nome del Database
  7. $tbl_name="utenti"; // Nome della Tabella
  8.  
  9. // Procedimento per connettersi al Database
  10.  
  11. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  12. mysql_select_db("$db_name")or die("cannot select DB");
  13.  
  14. // Nome utente e password inviate attraverso il form
  15.  
  16. $myusername=$_POST['myusername'];
  17. $mypassword=$_POST['mypassword'];
  18. $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
  19. $result=mysql_query($sql);
  20.  
  21. // Mysql_num_row is counting table row
  22.  
  23. $count=mysql_num_rows($result);
  24.  
  25. // If result matched $myusername and $mypassword, table row must be 1 row
  26.  
  27. if($count==1){
  28.  
  29. // Register $myusername, $mypassword and redirect to file "login_success.php"
  30.  
  31. $_SESSION['myusername'];
  32. $_SESSION['mypassword'];
  33. header("location:loginfatto.php");
  34. }
  35. else {
  36. echo "Attenzione username o password errati";
  37.  
  38.  
  39. }
  40. ?>
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