daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest May 31st, 2017 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.     <head>
  3.         <title> Panel Firmy </title>
  4.         <meta name="UTF-8">
  5.         <link rel="stylesheet" type="text/css" href="style.css">
  6.     </head>
  7.    
  8.     <body>
  9.         <center>
  10.         <br><br><br><br><br><br><br><br><br><br><br><br><br>
  11.             Panel
  12.            
  13.  
  14.        
  15.         <?php
  16.         /*
  17.         $servername = "localhost";
  18.             $username = "root";
  19.             $password = "";
  20.             $base = "database";
  21.            
  22.             $conn = new mysqli($servername, $username, $password, $base);
  23.             if ($conn->connect_error) {
  24.                 die("Connection failed: " . $conn->connect_error);
  25.                
  26.                
  27.     <------> II opcja      
  28.                
  29. define('DB_HOST', 'localhost');
  30. define('DB_NAME', 'practice');
  31. define('DB_USER','root');
  32. define('DB_PASSWORD','');
  33.  
  34. $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
  35. $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
  36. */             
  37.                
  38.         /*     
  39.         $ID = $_POST['login'];
  40.         $Password = $_POST['psw'];
  41.  
  42. function SignIn()
  43. {
  44. session_start();   //starting the session for user profile page
  45. if(!empty($_POST['login']))   //checking the 'user' name which is from formular, is it empty or have some text
  46. {
  47.     $query = mysql_query("SELECT *  FROM user where login = '$_POST[login]' AND pass = '$_POST[psw]'") or die(mysql_error());
  48.     $row = mysql_fetch_array($query) or die(mysql_error());
  49.     if(!empty($row['user']) AND !empty($row['psw']))
  50.     {
  51.         $_SESSION['user'] = $row['psw'];
  52.         echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
  53.  
  54.     }
  55.     else
  56.     {
  57.         echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
  58.     }
  59. }
  60. }
  61. if(isset($_POST['submit']))
  62. {
  63.     SignIn();
  64. }
  65.         */
  66.  
  67.  
  68.    define('DB_SERVER', 'localhost');
  69.    define('DB_USERNAME', 'root');
  70.    define('DB_PASSWORD', '');
  71.    define('DB_DATABASE', 'database');
  72.    $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
  73.    
  74.    
  75.     session_start();
  76.    
  77.    if($_SERVER["REQUEST_METHOD"] == "POST") {
  78.       // username and password sent from form
  79.      
  80.       $myusername = mysqli_real_escape_string($db,$_POST['login']);
  81.       $mypassword = mysqli_real_escape_string($db,$_POST['psw']);
  82.      
  83.       $sql = "SELECT id FROM user WHERE username = '$myusername' and passcode = '$mypassword'";
  84.       $result = mysqli_query($db,$sql);
  85.       $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  86.       $active = $row['active'];
  87.      
  88.       $count = mysqli_num_rows($result);
  89.      
  90.       // If result matched $myusername and $mypassword, table row must be 1 row
  91.        
  92.       if($count == 1) {
  93.          session_register("myusername");
  94.          $_SESSION['login_user'] = $myusername;
  95.          
  96.          header("location: welcome.php");
  97.       }else {
  98.          $error = "Your Login Name or Password is invalid";
  99.       }
  100.    }       
  101.         ?>
  102.                 </center>
  103.     </body>
  104. </html>
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