Advertisement
Guest User

Untitled

a guest
Aug 25th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'connection.php';
  4.  
  5. if(isset($_POST["username"]) and isset($_POST["password"]))
  6. {
  7.  
  8. $myusername=mysqli_real_escape_string($con,$_POST["username"]);
  9. $mypassword=mysqli_real_escape_string($con,$_POST["password"]);
  10. $sql="SELECT * from login WHERE username='$myusername' AND password='$mypassword'";
  11. $res=mysqli_query($con,$sql);
  12. if(mysqli_num_rows($res)==1)
  13. {
  14.  
  15. $query=$con->query("SELECT admin FROM login WHERE username='$myusername'");
  16. $array =array();
  17.  
  18. if (mysqli_num_rows($query))
  19. {
  20. $rows=mysqli_fetch_array($query);
  21. $admin=(($rows['admin']));
  22. if($admin)
  23. {
  24. $_SESSION['admin']=true;
  25. $_SESSION['u-name'] = $myusername;
  26. header("location:../happy_card/systemManegerInterface.php");
  27. exit();
  28. }
  29. else
  30. {
  31. $_SESSION['u-name'] = $myusername;
  32. $_SESSION['permission']=true;
  33. }
  34. }
  35.  
  36.  
  37. }
  38. else
  39. {
  40.  
  41. header("Location: home1.php?msg=4");
  42.  
  43. }
  44.  
  45. }
  46.  
  47. mysqli_close($con);
  48. ?>
  49.  
  50. <!DOCTYPE html>
  51. <html dir="rtl">
  52. <head>
  53.  
  54. <meta charset="utf-8" />
  55. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  56. <script>
  57.  
  58. function open()
  59. {
  60. var show = document.createElement("div");
  61. show.setAttribute("id", "show");
  62. $(document).ready(function() {
  63. $("li").click(function() {
  64. $("#show").text($(this).text());
  65. }
  66.  
  67. }
  68. }
  69. </script>
  70. <?php
  71.  
  72.  
  73. if(!isset($_SESSION['permission']))
  74. {
  75. session_destroy();
  76. echo "<script>window.location.href = '../happy_card/home1.php'</script>";
  77. exit();
  78. }
  79.  
  80. if(isset ($_POST['logout']))
  81. {
  82. session_destroy();
  83. echo "<script>window.location.href = '../happy_card/home1.php'</script>";
  84. exit();
  85. }
  86.  
  87. ?>
  88. <title>HAPPY CARD</title>
  89. <link rel="stylesheet" type="text/css" href="menu.css" />
  90. <meta charset="utf=8">
  91. <link rel="stylesheet" type="text/css" href="dynamicmenu.css" />
  92. <link rel="stylesheet" type="text/css" href="cards.css" />
  93. </head>
  94. <?php
  95. function loop_array($array=array() , $parent_id = 0)
  96. {
  97.  
  98. if(!empty($array[$parent_id]))
  99. {
  100.  
  101. echo '<ul class="cssmenu" style="color:#fff ;cursor: pointer;">';
  102. foreach ($array[$parent_id] as $items)
  103. {
  104. echo '<li>';
  105. echo '<a href=pages.php?pagename='.$items['link'].' >';
  106. echo $items['name'];
  107. echo '</a>';
  108. loop_array($array, $items['id']);
  109. echo '</li>';
  110. }
  111. echo '</ul>';
  112. }
  113. }
  114. function display_menus()
  115. {
  116. include 'connection.php';
  117. $query=$con->query("SELECT * FROM menu");
  118. $array =array();
  119.  
  120. if (mysqli_num_rows($query))
  121. {
  122. while($rows=mysqli_fetch_array($query))
  123. {
  124. $array[$rows['parent_id']][]=$rows;
  125. }
  126. }
  127. loop_array($array);
  128. }
  129.  
  130.  
  131. ?>
  132.  
  133. <body >
  134. <div class="holder">
  135. <div class="header">
  136. <div class="logo">
  137. </div>
  138. <?echo "ברוך הבא ".$_SESSION['u-name']."</br>";?>
  139. <form action=<?php echo $_SERVER["PHP_SELF"];?> method="post" enctype="multipart/form-data">
  140. <input type="submit" name="logout" value="התנתק" action=<?php echo $_SERVER["PHP_SELF"]?>;>
  141. </form>
  142. </div>
  143. <div class="menu">
  144. <div id="menu">
  145. <?php
  146. display_menus();
  147. ?>
  148. </div>
  149. </div>
  150.  
  151.  
  152.  
  153. <?php
  154. function loop_array2($array=array() , $parent_id = 0)
  155. {
  156. if(!empty($array[$parent_id]))
  157. {
  158. echo '<ul class="csscards" style="color:black; cursor: pointer;">';
  159. foreach ($array[$parent_id] as $items)
  160. {
  161. echo "<a href='editor.php?headline=".$items['headline']."&"."content=".$items['content']."'>";
  162. echo '<li>';
  163. echo $items['headline'].'<br>'.$items['content'] ;
  164. echo '</li>';
  165. echo "</a>";
  166. loop_array2($array, $items['id']);
  167.  
  168. }
  169. echo '</ul>';
  170. }
  171.  
  172. }
  173. function data()
  174. {
  175. $pagename = $_GET['pagename'];
  176. include 'connection.php';
  177. if(isset($pagename))
  178. {
  179. $query=$con->query("SELECT * FROM $pagename");
  180. $array =array();
  181. if (mysqli_num_rows($query))
  182. {
  183. while($rows=mysqli_fetch_array($query))
  184. {
  185. $array[$rows['parent_id']][]=$rows;
  186. }
  187. }
  188. loop_array2($array);
  189. }
  190. }
  191.  
  192.  
  193.  
  194. if($_GET['pagename']=='empty' || $_GET['pagename']=='home')
  195. {
  196. header("refresh:2; url=pages.php");
  197. }
  198. ?>
  199. <div class="content">
  200. <?php data(); ?>
  201. <div id="demo">
  202.  
  203. </div>
  204. </div>
  205. </div>
  206.  
  207. </body>
  208. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement