Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style type="text/css" language="css">
  4. #head{valign: top; text-align: center}
  5. #links{float: left}
  6. #type_list{display: none; position: relative; left:30px}
  7. #login{position: relative; left: 30px; top: 20px}
  8. </style>
  9.  
  10. <script type="text/javascript" language="javascript">
  11. function show_type_list()
  12. {
  13.     document.getElementById("type_list").style.display = "inline";
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body>
  19.  
  20. <!--Head of the page-->
  21. <div id="head">
  22. <h1>Login</h1>
  23. </div>
  24.  
  25. <!--Links; standard layout-->
  26. <!--could transfer these and make shtml-->
  27. <div id="links">
  28.     <dl>
  29.         <form name="type_list" >
  30.             <dt><a href="/index_files/display.php" style="text-decoration:none">Home</a></dt>
  31.             <dt><a href="#"  style="text-decoration:none" onclick="show_type_list()">Type</a></dt>
  32.             <div id="type_list">           
  33.                 <dd>Aeronautical</dd>
  34.                 <dd>Architectural</dd>
  35.                 <dd>Bioengineering</dd>
  36.                 <dd>Chemical/Petrolum</dd>
  37.                 <dd>Civil</dd>
  38.                 <dd>Computer Science</dd>
  39.                 <dd>Electrical</dd>
  40.                 <dd>Engineering Management</dd>
  41.                 <dd>Engineering Physics</dd>
  42.                 <dd>Mechanical</dd>
  43.             </div>
  44.         </form>
  45.  
  46.         <dt><a href="/index_files/upload_form-1.php"  style="text-decoration:none">Upload</a></dt>
  47.  
  48.         <dt><a href="/index_files/login_page.php" style="text-decoration:none">Login</a></dt>
  49.     </dl>
  50. </div>
  51.  
  52. <!--Login form-->
  53.  
  54. <div id="login">
  55.     <form name="login" onSubmit="validate_form()" action="login.php" enctype="multipart/form-data" method="post">
  56.         Username: <input type="text" name="username" />
  57.         <br />
  58.         Password: <input type="password" name="password" />
  59.         <br />
  60.         <input type="submit" value="Login" />
  61.     </form>
  62. </div>
  63.  
  64. </body>
  65. </html>
  66.  
  67.  
  68. page 2
  69.  
  70.  
  71. <?php
  72.  
  73.  
  74. if($_SESSION['authenticate'] == "")
  75.     {
  76.  
  77.     //declaration of variables
  78.         //creating connection to serve
  79.     $con = mysql_connect("localhost","username","pass") or die('Could not connect to server' . mysql_error());
  80.     $table = "user_pass";
  81.     $db = "whackand_wikieng";
  82.  
  83.         //making user input safe
  84.     mysql_select_db($db, $con);
  85.     $username = mysql_real_escape_string($_POST['username']);
  86.     $password = mysql_real_escape_string($_POST['password']);
  87.    
  88.     $result = mysql_query("SELECT Number FROM $table WHERE Username='$username' AND  Password='$password'") or die(mysql_error());
  89.     $row = mysql_fetch_array( $result );
  90.     $id = (int)$row['Number'];
  91.    
  92.  
  93.     if($id > 0)
  94.         {
  95.         session_start();
  96.         /*$_SESSION['Username'] = $Username;
  97.         $_SESSION['Id'] = $Id;*/
  98.         $_SESSION['Authenticate'] = 1;
  99.         header("Location: upload_form-1.php");
  100.         }
  101.     else
  102.         {
  103.         session_start();
  104.         $_SESSION['authenticate'] = "";
  105.         echo "You are not allowed to upload files." . "<br />";
  106.        
  107.         echo $username . "<br />";
  108.         echo $password . "<br />";
  109.    
  110.         echo $result . "<br />";
  111.         echo $row . "<br />";
  112.         echo $id . "<br />";
  113.         }
  114.  
  115.     //closing server connection
  116.     mysql_close($con);
  117.  
  118.     }
  119.  
  120. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement