Advertisement
Guest User

index.php

a guest
Sep 21st, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.79 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. if (isset($_SESSION['Username'])) {
  5. ?><meta http-equiv="refresh" content="0; url=<? $site; ?>/start.php">
  6. <? }
  7.  
  8. $aa = 0;
  9. include ('config.php');
  10. if (isset($_POST['formsubmitted'])) {
  11. // Initialize a session:
  12. session_start();
  13. $error = array(); //this aaray will store all error messages
  14.  
  15.  
  16. if (empty($_POST['Username'])) {//if the email supplied is empty
  17. $error[] = 'You forgot to enter your Email ';
  18. } else {
  19. $Username = $_POST['Username'];
  20. }
  21.  
  22.  
  23. if (empty($_POST['Password'])) {
  24. $error[] = 'Please Enter Your Password ';
  25. } else {
  26. $Password = $_POST['Password'];
  27. }
  28.  
  29.  
  30. if (empty($error)) {//if the array is empty , it means no error found
  31. $query_check_credentials = "SELECT * FROM members WHERE (Username='$Username' AND password='$Password') AND Activation IS NULL";
  32.  
  33.  
  34.  
  35. $result_check_credentials = mysqli_query($dbc, $query_check_credentials);
  36. if (!$result_check_credentials) {//If the QUery Failed
  37. echo 'Query Failed ';
  38. }
  39.  
  40. if (@mysqli_num_rows($result_check_credentials) == 1) {//if Query is successfull // A match was made.
  41. $_SESSION = mysqli_fetch_array($result_check_credentials, MYSQLI_ASSOC); //Assign the result of this query to SESSION Global Variable
  42. ?><meta http-equiv="refresh" content="0; url=<? echo $site; ?>/start.php"><?
  43. } else {
  44.  
  45. $msg_error = 'Either Your Account is inactive or Username /Password is Incorrect';
  46. }
  47. } else {
  48.  
  49.  
  50.  
  51. echo '<div class="errormsgbox"> <ol>';
  52. foreach ($error as $key => $values) {
  53.  
  54. echo ' <li>' . $values . '</li>';
  55. }
  56. echo '</ol></div>';
  57. }
  58.  
  59.  
  60. if (isset($msg_error)) {
  61.  
  62. $aa = 1;
  63. }
  64. var_dump($error);
  65. mysqli_close($dbc);
  66. } // End of the main Submit conditional.
  67. ?>
  68.  
  69.  
  70. <!DOCTYPE html>
  71. <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
  72. <!--[if IE 7 ]> <html lang="en" class="no-js ie7 lt8"> <![endif]-->
  73. <!--[if IE 8 ]> <html lang="en" class="no-js ie8 lt8"> <![endif]-->
  74. <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
  75. <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
  76. <head>
  77. <meta charset="UTF-8" />
  78. <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
  79. <title><? echo $sitetitle; ?></title>
  80. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  81.  
  82.  
  83. <link rel="stylesheet" type="text/css" href="css/demo.css" />
  84. <link rel="stylesheet" type="text/css" href="css/style3.css" />
  85. <link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
  86. </head>
  87. <body>
  88. <div class="container">
  89. <!-- Codrops top bar -->
  90. <div class="codrops-top">
  91. <a href="<? echo $site; ?>/leader.php">
  92. <strong>See the Leader Board</strong>
  93. </a>
  94. <span class="right">
  95. <a href="<? echo $site; ?>/rules.php">
  96. <strong>Read the Rules</strong>
  97. </a>
  98. </span>
  99. <div class="clr"></div>
  100. </div><!--/ Codrops top bar -->
  101. <header>
  102. <h1><? echo $sitetitle; ?></h1>
  103.  
  104. </header>
  105. <section>
  106. <div id="container_demo" >
  107.  
  108. <a class="hiddenanchor" id="toregister"></a>
  109. <a class="hiddenanchor" id="tologin"></a>
  110. <div id="wrapper">
  111. <div id="login" class="animate form">
  112. <form method="post" action="index.php" autocomplete="on">
  113. <h1>Log in</h1>
  114.  
  115.  
  116.  
  117. <? if (!isset($_SESSION['Username'])) {
  118. ?><?
  119. } else {
  120. ?><li><a href="/logout.php">Logout</a></li><? }
  121. ?>
  122. </ul>
  123. </nav>
  124.  
  125. <? if (!isset($_SESSION['Username'])) {
  126. ?>
  127. <form method="post" action="index.php" class="login">
  128.  
  129. <p>
  130. <label for="username" class="uname" data-icon="u" > </br> </label>
  131. <input name="Username" required="required" type="text" id="Username" placeholder="Username">
  132. </p>
  133.  
  134. <p><label for="password" class="youpasswd" data-icon="p"> </br> </label>
  135. <input name="Password" required="required" type="password" id="Password" placeholder="Password">
  136. </p>
  137.  
  138. <input type="hidden" name="formsubmitted" value="TRUE" />
  139. <p class="login button">
  140. <input type="submit" value="Login" />
  141.  
  142. </p>
  143.  
  144. <p class="forgot-password"><a href="forgot.php">Forgot password?</a></p>
  145. </form>
  146. <? } ?>
  147.  
  148.  
  149. <p class="change_link">
  150. Not a member yet
  151. <a href="#toregister" class="to_register">Join us</a>
  152. </p>
  153. </form>
  154. </div>
  155.  
  156.  
  157. <div id="register" class="animate form">
  158. <form method="post" action="register.php" autocomplete="on">
  159. <h1> Sign up </h1>
  160. <p> <label for="username" class="uname" data-icon="u" > </br></label>
  161. <input placeholder="Your Name" id="n" name="n" required="required" type="text" />
  162. </p>
  163. <p> <label for="emailsignup" class="youmail" data-icon="e" > </br> </label>
  164. <input id="e-mail" name="e-mail" required="required" type="email" placeholder="Your Email"/>
  165. </p>
  166.  
  167. <p> <label for="username" class="uname" data-icon="u" > </br> </label>
  168. <input name="schoolname" required="required" type="text" placeholder="School Name" id="schoolname"/>
  169. </p>
  170. <p> <label for="username" class="uname" data-icon="u" > </br> </label>
  171. <input id="name" name="name" required="required" type="text" placeholder="Your Username" />
  172. </p>
  173. <p> <label for="password" class="youpasswd" data-icon="p"> </br> </label>
  174. <input id="Password" name="Password" required="required" type="password" placeholder="Password"/>
  175. </p>
  176. <p class="signin button">
  177. <input type="hidden" name="formsubmitted" value="TRUE" />
  178. <input type="submit" name="send" value="Register" id="submit" />
  179. </p>
  180. <p class="change_link">
  181. Already a member
  182. <a href="#tologin" class="to_register"> Go and log in </a>
  183. </p>
  184. </form>
  185. </div>
  186.  
  187. </div>
  188. </div>
  189. </section>
  190. </div>
  191. </body>
  192. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement