Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.40 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Login</title>
  5. <style>
  6. .warnings{
  7.     width:100%;
  8.  
  9.     /* Firefox */
  10.     display:-moz-box;
  11.     -moz-box-pack:center;
  12.     -moz-box-align:center;
  13.  
  14.     /* Safari and Chrome */
  15.     display:-webkit-box;
  16.     -webkit-box-pack:center;
  17.     -webkit-box-align:center;
  18.  
  19.     /* W3C */
  20.     display:box;
  21.     box-pack:center;
  22.     box-align:center;
  23. }
  24. .logo{
  25.     width:100%;
  26.  
  27.     /* Firefox */
  28.     display:-moz-box;
  29.     -moz-box-pack:center;
  30.     -moz-box-align:center;
  31.  
  32.     /* Safari and Chrome */
  33.     display:-webkit-box;
  34.     -webkit-box-pack:center;
  35.     -webkit-box-align:center;
  36.  
  37.     /* W3C */
  38.     display:box;
  39.     box-pack:center;
  40.     box-align:center;
  41. }
  42. .login_form{
  43.     width:100%;
  44.  
  45.     /* Firefox */
  46.     display:-moz-box;
  47.     -moz-box-pack:center;
  48.     -moz-box-align:center;
  49.  
  50.     /* Safari and Chrome */
  51.     display:-webkit-box;
  52.     -webkit-box-pack:center;
  53.     -webkit-box-align:center;
  54.  
  55.     /* W3C */
  56.     display:box;
  57.     box-pack:center;
  58.     box-align:center;
  59.  
  60. }
  61. </style>
  62. </head>
  63. <body style="background-color:#f9c466;">
  64.  
  65. <div class="logo">
  66. <img src="images/lucyslogo.png" alt="LucysLogo" style="width:140px;height:100px;">
  67. </div>
  68. <div class="login_form">
  69. </br>
  70. <form action="" method="POST">
  71. Username: </br> <input type="text" name="user"></br>
  72. Password: </br> <input type="password" name="pass"></br>
  73. </br>  
  74. <input type="submit" value="Login" name="submit" />
  75. <input type="button" class="button_active" value="Register" onclick="location.href='register.php';" />
  76.  
  77. </form>
  78.  
  79. <?php
  80. if(isset($_POST["submit"])){
  81.  
  82. if(!empty($_POST['user']) && !empty($_POST['pass'])) {
  83.     $user=$_POST['user'];
  84.     $pass=$_POST['pass'];
  85.  
  86.     $con=mysql_connect('localhost','ncc','ncc') or die(mysql_error());
  87.     mysql_select_db('ncc') or die("cannot select DB");
  88.  
  89.     $query=mysql_query("SELECT * FROM login WHERE username='".$user."' AND password='".$pass."'");
  90.     $numrows=mysql_num_rows($query);
  91.     if($numrows!=0)
  92.     {
  93.     while($row=mysql_fetch_assoc($query))
  94.     {
  95.     $dbusername=$row['username'];
  96.     $dbpassword=$row['password'];
  97.     }
  98.  
  99.     if($user == $dbusername && $pass == $dbpassword)
  100.     {
  101.     session_start();
  102.     $_SESSION['sess_user']=$user;
  103.  
  104.     /* Redirect browser */
  105.     header("Location: member.php");
  106.     }
  107.     } else {
  108.     $login_invalid="Invalid username or password!";
  109.     }
  110.  
  111. } else {
  112.     $login_required="All fields are required!";
  113. }
  114. }
  115. ?>
  116. </div>
  117. </br>
  118. </br>
  119. <div class="warnings"><?php
  120. echo "<b>".$login_invalid."<b>";
  121. echo "<b>".$login_required."<b>";
  122. ?>
  123. </div>
  124.  
  125. </body>
  126. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement