Advertisement
Guest User

Login.php

a guest
Mar 11th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. <!--
  2.  
  3. Daniel Butler
  4. U27A2
  5. Coded In HTML/PHP
  6. Last Used 11/03/2016
  7.  
  8. -->
  9.  
  10.  
  11. <!-- Most of the code in this is file consists of work from a privous unit (U28) therefor I will not be commenting it, however I will comment on the work for this Unit -->
  12.  
  13. <html>
  14. <head>
  15. <style>
  16. form{ padding:30px }
  17. body {
  18. background-image: url("bgimage.png");
  19. background-size: 150px 150px;
  20. text-shadow: 2x 2px #ff0000;
  21. }
  22. </style>
  23.  
  24. <script type="text/javascript">
  25. <!--
  26. function MM_jumpMenu(targ,selObj,restore){ //v3.0
  27. eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  28. if (restore) selObj.selectedIndex=0;
  29. }
  30. //-->
  31. </script>
  32. </head>
  33.  
  34.  
  35.  
  36. <body>
  37.  
  38. <!-- Here is the code that allows the user to log in. This is where the user will input their details. This code shows how to manage the variables and the data that the user inputs -->
  39.  
  40.  
  41. <div style="background-color:green; height:220px; width:100%; boder:#000; border:thick; border:solid">
  42.  
  43. <!-- Above is the style for the top bar -->
  44.  
  45.  
  46. <p style=text-align:"left"><img src="http://i.imgur.com/TEIGvv1.png" height="200px" width="200px" alt="pat a cake Logo">
  47. <img src="http://i.imgur.com/yTgziaC.png" width="1010px" alt="Some Cake Shop logo" height="200px">
  48. </p>
  49.  
  50.  
  51. <p style="text-align:center">
  52. </p>
  53.  
  54. </div>
  55.  
  56.  
  57. <div style="background-color:yellow; width:20%; float:left">
  58.  
  59.  
  60. <!-- Above is the style for the side bar with the menu on -->
  61.  
  62.  
  63.  
  64.  
  65. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="homepage.html"> Home </a> </p>
  66. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="makeacake.html"> Make A Cake </a> </p>
  67. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="login.php"> Login </a>
  68. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="browser-res.php"> Check Browser/Resolution </a>
  69. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="cakelist.html"> Our Prices </a>
  70. <select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
  71.  
  72. <option value="US.html">US</option>
  73. <option value="UK.html">UK</option>
  74. </select>
  75. </p>
  76. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="about.html"> About Us </a> </p>
  77.  
  78.  
  79.  
  80. <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/hashtag/cakes" data-widget-id="606740900606279680">#cakes Tweets</a>
  81. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  82.  
  83. </div>
  84.  
  85.  
  86.  
  87.  
  88. <!-- Above is the menu -->
  89.  
  90.  
  91. <div style="background-color:pink; width:79.9%; float:left">
  92.  
  93.  
  94. <!-- Above is the style for the main div -->
  95.  
  96.  
  97. <!-- This is where the user will input their username and password, this code creates a table with the fields of "User name" and "Password" -->
  98.  
  99. <?php
  100. $user = $_POST["username"];
  101. $pass = $_POST["password"];
  102. $validated = false;
  103. $myfile = fopen("errorfile.txt", "a");
  104.  
  105. session_start();
  106. $_SESSION['login'] = "";
  107. if($user!="" && $pass!="")
  108. {
  109.  
  110. // Here is where the database containing the logins in connected to.
  111.  
  112. $conn = @mysql_connect("localhost","nditbutlerd","10723282") or die ("Sorry - unable to connect to database.");
  113. $rs = @mysql_select_db("nditbutlerd",$conn) or die ("error");
  114. $sql = "SELECT * FROM user WHERE username = '$user' AND password = '$pass'";
  115. $rs = mysql_query($sql,$conn);
  116. $result = mysql_num_rows($rs);
  117.  
  118. // If the userinputs a valid username and passwork this code will run.
  119.  
  120. if($result > 0) $validated = true;
  121. if($validated)
  122. {
  123. $_SESSION['login'] = "OK";
  124. $_SESSION['username'] = $user;
  125. $_SESSION['password'] = $pass;
  126. header('Location: Logged_in.php');
  127. }
  128. else
  129. {
  130.  
  131. // If the user inputs the incorrect loggin details then a message saying "Incorrect username or password" will be desplayed.
  132. $_SESSION['login'] = "";
  133. echo "<br><h1 align=center style=color:Red;>Invalid username or password.</h1><br>";
  134. fwrite($myfile, "A user tried logging in using the username:" . $_POST['$user'] . "/npassword:" . $_POST['$pass'] . "\n\n");
  135. }
  136. }
  137. else $_SESSION['login'] = "";
  138. ?>
  139.  
  140. <h1 align="center">Login Page</h1>
  141. <p align="center">Please put in your username and your password</p>
  142. <form action="login.php" method="post">
  143. <table align="center">
  144. <tr>
  145. <td align="right">Username:</td>
  146. <td><input type="password" size="20" maxlength="15" name="username"></td>
  147. </tr>
  148. <tr>
  149. <td align="right">Password:</td>
  150. <td><input type="password" size="20" maxlength="15" name="password"></td>
  151. </tr>
  152. <tr>
  153. <td></td>
  154. <td colspan ="2" align"left"><input type="submit" value="Login"></td>
  155. </tr>
  156. </table>
  157. </form>
  158.  
  159.  
  160. </div>
  161.  
  162. <div style="background-color:grey; width:100%; clear:both">
  163.  
  164. <!-- Above is the style for the bottom bar -->
  165.  
  166. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="about.html"> About Us </a> </p>
  167. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="homepage.html"> Home </a> </p>
  168. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="makeacake.html"> Make A Cake </a> </p>
  169. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="cakelist.html"> Our Prices </a>
  170. </div>
  171.  
  172. </body>
  173.  
  174.  
  175.  
  176.  
  177. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement