Advertisement
Guest User

Logged in.php

a guest
Mar 11th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 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. <body>
  35.  
  36.  
  37.  
  38. <div style="background-color:green; height:220px; width:100%; boder:#000; border:thick; border:solid">
  39.  
  40. <!-- Above is the style for the top bar -->
  41.  
  42.  
  43. <p style=text-align:"left"><img src="http://i.imgur.com/TEIGvv1.png" height="200px" width="200px" alt="pat a cake Logo">
  44. <img src="http://i.imgur.com/yTgziaC.png" width="1010px" alt="Some Cake Shop logo" height="200px">
  45. </p>
  46.  
  47.  
  48. <p style="text-align:center">
  49. </p>
  50.  
  51. </div>
  52.  
  53.  
  54. <div style="background-color:yellow; width:20%; float:left">
  55.  
  56.  
  57. <!-- Above is the style for the side bar with the menu on -->
  58.  
  59.  
  60.  
  61.  
  62. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="homepage.html"> Home </a> </p>
  63. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="makeacake.html"> Make A Cake </a> </p>
  64. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="login.php"> Login </a>
  65. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="browser-res.php"> Check Browser/Resolution </a>
  66. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="cakelist.html"> Our Prices </a>
  67. <select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
  68.  
  69. <option value="US.html">US</option>
  70. <option value="UK.html">UK</option>
  71. </select>
  72. </p>
  73. <p style="boder:#000; border:thick; border:solid; background-color:#CCC"><a href="about.html"> About Us </a> </p>
  74.  
  75.  
  76.  
  77. <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/hashtag/cakes" data-widget-id="606740900606279680">#cakes Tweets</a>
  78. <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>
  79.  
  80. </div>
  81.  
  82.  
  83.  
  84.  
  85. <!-- Above is the menu -->
  86.  
  87.  
  88. <div style="background-color:pink; width:79.9%; float:left">
  89.  
  90.  
  91. <!-- Above is the style for the main div -->
  92.  
  93. <!-- This is the php code to input the variables from "login.php" This code outputs the users information onto the screen and if they are logged in as an admin they will be directed to a different page. -->
  94.  
  95. <?php
  96. $user = $_POST["username"];
  97. $pass = $_POST["password"];
  98. $validated = false;
  99.  
  100. session_start();
  101. $_SESSION['login'] = "";
  102. if($user!="" && $pass!="")
  103. {
  104. $conn = @mysql_connect("localhost","nditbutlerd","10723282") or die ("Sorry - unable to connect to database.");
  105. $rs = @mysql_select_db("nditbutlerd",$conn) or die ("error");
  106. $sql = "SELECT * FROM user WHERE username = '$user' AND password = '$pass'";
  107. $rs = mysql_query($sql,$conn);
  108. $result = mysql_num_rows($rs);
  109.  
  110. if($result > 0) $validated = true;
  111. if($validated)
  112. {
  113. $_SESSION['login'] = "OK";
  114. $_SESSION['username'] = $user;
  115. $_SESSION['password'] = $pass;
  116. header('Location: protected.php');
  117. }
  118. else
  119. {
  120. $_SESSION['login'] = "";
  121. echo "Invalid username or password.";
  122. }
  123. }
  124. else $_SESSION['login'] = "";
  125. ?>
  126.  
  127. <?php
  128.  
  129. echo "<p align=center>You have logged in!</p>";
  130. echo "<p align=center>Your username is: ";
  131. echo $_SESSION['username'];
  132. echo "<br/>";
  133. echo "Your password is: ";
  134. echo $_SESSION['password'];
  135. echo "</p>";
  136.  
  137. // If i log in using "DanButler" and "DanPass" i will be directed to my personalized page that welcomes me and gives me access to some admin features that anyone else would not have access to.
  138.  
  139. if ($_SESSION['username'] == 'DanButler')
  140. {
  141. echo "<h1 align=center>WELCOME DAN!</h1>";
  142. echo "<p align=center>As you are an Admin, you have access to creating a contact details text document</p>";
  143. echo "<p align=center style=boder:#000; border:thick; border:solid; background-color:#CCC><a href=create_contact.html> Click here to do so! </a>";
  144.  
  145. // If an admin logs in using "Admin" and "letmein" they will be directed to an admin page where they have access to admin features.
  146.  
  147. }
  148.  
  149. if ($_SESSION['username'] == 'admin')
  150. {
  151. echo "<p align=center style=boder:#000; ><a href='create_user.php'>Create a new user</a></p>";
  152. }
  153.  
  154.  
  155. ?>
  156.  
  157. </div>
  158.  
  159. <div style="background-color:grey; width:100%; clear:both">
  160.  
  161. <!-- Above is the style for the bottom bar -->
  162.  
  163. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="about.html"> About Us </a> </p>
  164. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="homepage.html"> Home </a> </p>
  165. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="makeacake.html"> Make A Cake </a> </p>
  166. <p style="boder:#000; border:thick; border:solid; background-color:#CCC" align="center"><a href="cakelist.html"> Our Prices </a>
  167. </div>
  168.  
  169. </body>
  170.  
  171.  
  172.  
  173.  
  174. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement