Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL & ~E_NOTICE);
  3. error_reporting(E_ERROR | E_PARSE);
  4. session_start();
  5. ?>
  6. /* This Code */
  7. <?php
  8.  
  9. if(isset($_POST["Register"]))
  10. {
  11. $servername = "localhost";
  12. $username = "root";
  13. $password = "";
  14. $dbname = "dbuseraccounts";
  15.  
  16. // Create connection
  17. $conn = new mysqli($servername, $username, $password, $dbname);
  18. // Check connection
  19. if ($conn->connect_error) {
  20. die("Connection failed: " . $conn->connect_error);
  21. }
  22.  
  23.  
  24. $user = $_POST['Username'];
  25. $pass = $_POST['Password'];
  26.  
  27. $query = mysqli_query($conn, "SELECT * FROM users WHERE Username= '".$user."'");
  28.  
  29. if(mysqli_num_rows($query) > 0)
  30. {
  31. echo "<script type='text/javascript'>UserExist();</script>";
  32. }
  33. else
  34. {
  35. $insertdata = "INSERT INTO `users` (`Username`, `Password`, `FirstName`, `LastName`, `Email`, `ContactNumber`)
  36. VALUES ('".$_POST["Username"]."','".$_POST["Password"]."','".$_POST["FirstName"]."','".$_POST["LastName"]."','".$_POST["Email"]."','".$_POST["ContactNumber"]."')";
  37.  
  38. if ($conn->query($insertdata) === TRUE)
  39. {
  40. echo "<script type='text/javascript'>Success();</script>";
  41. header("Location:Login.php");
  42. }
  43. else
  44. {
  45. echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";
  46. }
  47. }
  48.  
  49. $conn->close();
  50. }
  51. ?>
  52. /* This Code */
  53.  
  54.  
  55. <!doctype html>
  56. <html>
  57. <head>
  58. <meta charset="utf-8">
  59. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  60. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  61. <title>Register</title>
  62. <link href="css/bootstrap.css" rel="stylesheet" type="text/css">
  63. <link href="css/stylesheet.css" rel="stylesheet" type="text/css">
  64. <style type="text/css">
  65. body {
  66. margin-left: 0px;
  67. margin-right: 0px;
  68. }
  69. </style>
  70. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  71. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  72. <!--[if lt IE 9]>
  73. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  74. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  75. <![endif]-->
  76. </head>
  77. <body>
  78. <div class="wrapper">
  79. <div class="container-fluid">
  80. <ul class="topnav" id="myTopnav">
  81. <li class="li_left"><a href="Home.php">Home</a></li>
  82. <li class="li_left"><a href="Services.php">Services</a></li>
  83. <li class="li_left"><a href="Promo.php">Promo</a></li>
  84. <li class="li_left"><a href="AboutUs.php">About Us</a></li>
  85. <li class="li_left"><a href="ContactUs.php">Contact Us</a></li>
  86. <li class="li_left"><a href="Appointment.php">Appointment</a></li>
  87. <li class="li_left"><a id="appointmentlist" href="Appointmentlist.php">Appointment List</a></li>
  88.  
  89. <li class="li_right"><a id="logout" href="logout.php">Logout</a></li>
  90. <li class="li_right"><a id="user" href="User.php"><?php echo $_SESSION['Username']; ?></a></li>
  91. <li class="li_right"><a id="login" href="Login.php">Log In</a></li>
  92. <li class="li_right"><a id="register" href="Register.php">Register</a></li>
  93. <li class="icon">
  94. <a href="javascript:void(0);" onclick="myFunction()">&#9776;</a>
  95. </li>
  96. </ul>
  97. <div style="height:620px"; >
  98. <h1 class="heading" >Register</h1>
  99. <form id="RegisterForm" name="RegisterForm" method="post">
  100. <div class="FormElement"><input name="Username" type="text" autofocus required="required" class="TField" id= "Username" maxlength="20" placeholder="Username"></div>
  101. <div class="FormElement"><input name="Password" type="password" required="required" class="TField" id="Password" maxlength="20" placeholder="Password"></div>
  102. <div class="FormElement"><input name="FirstName" type="text" autofocus required="required" class="TField" id= "FirstName" maxlength="20" placeholder="First Name"></div>
  103. <div class="FormElement"><input name="LastName" type="text" required="required" class="TField" id="LastName" maxlength="20" placeholder="Last Name"></div>
  104. <div class="FormElement"><input name="Email" type="email" required="required" class="TField" id="Email" maxlength="30" placeholder="Email Address"></div>
  105. <div class="FormElement"><input name="ContactNumber" type="number" required="required" class="TField" id="ContactNumber" maxlength="20" placeholder="Contact Number"></div>
  106. <div class="FormElement">
  107. <div id="alert">
  108. <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  109. User Already Exists
  110. </div>
  111. <div id="success">
  112. <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  113. You Are Now Registered
  114. </div>
  115. <input name="Register" type="submit" class="button" id="Register" value="Register">
  116. </div>
  117. </form>
  118. </div>
  119. <div class="footer">
  120. <footer></footer>
  121. </div>
  122. </div>
  123. <script src="js/jquery-1.11.3.min.js"></script>
  124. <script src="js/bootstrap.js"></script>
  125.  
  126. <script>
  127. function myFunction() {
  128. var x = document.getElementById("myTopnav");
  129. if (x.className === "topnav") {
  130. x.className += " responsive";
  131. } else {
  132. x.className = "topnav";
  133. }
  134. }
  135. </script>
  136.  
  137. <script>
  138. function UserExist()
  139. {
  140. document.getElementById("alert").style.display = "block";
  141. }
  142. </script>
  143.  
  144. <script>
  145. function Success()
  146. {
  147. document.getElementById("success").style.display = "block";
  148. }
  149. </script>
  150.  
  151. <script>
  152. function IfLoginAdminFunction()
  153. {
  154. document.getElementById("login").style.display = "none";
  155. document.getElementById("register").style.display = "none";
  156. document.getElementById("logout").style.display = "block";
  157. }
  158. </script>
  159.  
  160. <script>
  161. function IfLoginNotAdminFunction()
  162. {
  163. document.getElementById("login").style.display = "none";
  164. document.getElementById("register").style.display = "none";
  165. document.getElementById("appointmentlist").style.display = "none";
  166. document.getElementById("logout").style.display = "block";
  167. }
  168. </script>
  169.  
  170. <script>
  171. function IfNotLoginFunction()
  172. {
  173. document.getElementById("logout").style.display = "none";
  174. document.getElementById("user").style.display = "none";
  175. document.getElementById("appointmentlist").style.display = "none";
  176. }
  177. </script>
  178.  
  179. <?php
  180.  
  181. if (isset($_SESSION['login']) && $_SESSION['login'] == true)
  182. //if login
  183. {
  184. if($_SESSION['Type'] == 1)
  185. {
  186. echo "<script type='text/javascript'>IfLoginAdminFunction();</script>";
  187. }
  188. elseif($_SESSION['Type'] == 0)
  189. {
  190. echo "<script type='text/javascript'>IfLoginNotAdminFunction();</script>";
  191. }
  192. }
  193. //if not login
  194. else
  195. {
  196. echo "<script type='text/javascript'>IfNotLoginFunction();</script>";
  197. }
  198. ?>
  199.  
  200.  
  201. </body>
  202. </html>
  203.  
  204. <?php
  205. //do all the redirecting stuff etc
  206. $code="";
  207. if($sth){
  208. $code="<script>alert(':)');</script>";
  209. }
  210. ?>
  211. <html>
  212. <head>
  213. <?php echo $code;?>
  214. </head>
  215. <body>
  216. if $sth is true, you will see a :)
  217. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement