Advertisement
Guest User

CWang

a guest
Jul 13th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.87 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <?php
  4. require_once "dbcomm.php";
  5. //create db connection
  6. $dbcomm = new dbcomm();
  7.  
  8. $errorCount = 0;
  9.  
  10. if(isset($_POST['form-username'])) {
  11. if(1==2) {
  12. $errorCount++;
  13. $alert .= '<div class="alert alert-danger alert-dismissible" role="alert">
  14. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  15. <strong>Error!</strong> This Account ID is already used.</div>';
  16. }
  17. }
  18. if(isset($_POST['form-password'])) {
  19. $password = filter_var($_POST['form-password'], FILTER_SANITIZE_STRING);
  20. $uppercase = preg_match('@[A-Z]@', $password);
  21. $lowercase = preg_match('@[a-z]@', $password);
  22. $number = preg_match('@[0-9]@', $password);
  23. if (!$uppercase || !$lowercase || !$number || strlen($password) < 8) {
  24. $errorCount++;
  25. $alert .= '<div class="alert alert-danger alert-dismissible" role="alert">
  26. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  27. <strong>Error!</strong> Your password does not meet the requirements.</div>';
  28. }
  29. }
  30. if(isset($_POST['form-repassword']) and $_POST['form-password']) {
  31. $repassword = filter_var($_POST['form-repassword'], FILTER_SANITIZE_STRING);
  32. if($repassword != $_POST['form-password']) {
  33. $errorCount++;
  34. $alert .= '<div class="alert alert-danger alert-dismissible" role="alert">
  35. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  36. <strong>Error!</strong> The passwords do not match.</div>';
  37. }
  38. }
  39. if (isset($_POST['form-phonenumber'])){
  40. if(!preg_match("/^\(\d{3}\) \d{3}-\d{4}$/", $_POST['form-phonenumber'])){
  41. $errorCount++;
  42. $alert .= '<div class="alert alert-danger alert-dismissible" role="alert">
  43. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  44. <strong>Error!</strong> Invalid phone number.</div>';
  45. }
  46. }
  47. if(isset($_POST["form-email"])){
  48. if (!filter_var($_POST["form-email"], FILTER_VALIDATE_EMAIL)) {
  49. $errorCount++;
  50. $alert .= '<div class="alert alert-danger alert-dismissible" role="alert">
  51. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  52. <strong>Error!</strong> Invalid email.</div>';
  53. }
  54. }
  55.  
  56. if ($errorCount == 0 && isset($_POST['form-password'])) {
  57. $username = $_POST['form-username'];
  58. $password = sha1($_POST['form-password']);
  59. $email = $_POST['form-email'];
  60. $phonenumber = preg_replace('/\D+/', '', $_POST['form-phonenumber']);
  61.  
  62. if($dbcomm->checkIfUsernameExists($username)) {
  63. $errorCount += 1;
  64. $alert .= '<div class="alert alert-warning alert-dismissible" role="alert">
  65. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  66. <strong>Sorry!</strong> That username is already in use.</div>';
  67. }
  68. if($dbcomm->checkIfPhonenumberExists($phonenumber)) {
  69. $errorCount += 1;
  70. $alert .= '<div class="alert alert-warning alert-dismissible" role="alert">
  71. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  72. <strong>Sorry!</strong> That phone number is already associated with an account.</div>';
  73. }
  74. if($dbcomm->checkIfEmailExists($email)) {
  75. $errorCount += 1;
  76. $alert .= '<div class="alert alert-warning alert-dismissible" role="alert">
  77. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  78. <strong>Sorry!</strong> That email is already associated with an account.</div>';
  79. }
  80. if ($errorCount == 0) {
  81. $dbcomm->createNewUser($username, $password, $email, $phonenumber);
  82. echo "<script>window.location = 'homepage.php'</script>";
  83. }
  84. }
  85. else {
  86. echo "<script>document.getElementById(\"form-password\").innerHTML = \"\";</script>";
  87. echo "<script>document.getElementById(\"form-repassword\").innerHTML = \"\";</script>";
  88. }
  89.  
  90. ?>
  91.  
  92. <html lang="en">
  93.  
  94. <head>
  95.  
  96. <meta charset="utf-8">
  97. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  98. <meta name="viewport" content="width=device-width, initial-scale=1">
  99. <title>Planbook Login</title>
  100.  
  101. <!-- CSS -->
  102. <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
  103. <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  104. <link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
  105. <link rel="stylesheet" href="assets/css/form-elements.css">
  106. <link rel="stylesheet" href="assets/css/style.css">
  107.  
  108. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  109. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  110. <!--[if lt IE 9]>
  111. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  112. <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  113. <![endif]-->
  114.  
  115. <!-- Favicon and touch icons -->
  116. <link rel="shortcut icon" href="assets/ico/favicon.png">
  117. <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
  118. <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
  119. <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
  120. <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
  121.  
  122. </head>
  123.  
  124. <body>
  125. <nav id="mainNav" class="navbar navbar-default navbar-fixed-top navbar-custom">
  126. <div class="container">
  127. <!-- Brand and toggle get grouped for better mobile display -->
  128. <div class="navbar-header page-scroll">
  129. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  130. <span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
  131. </button>
  132. <a class="navbar-brand" href="index.html">Planbook</a>
  133. </div>
  134.  
  135. <!-- Collect the nav links, forms, and other content for toggling -->
  136. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  137. <ul class="nav navbar-nav navbar-right">
  138. <li>
  139. <a href ="signin.php">Sign In/Sign up</a>
  140. </li>
  141. <li class="page-scroll">
  142. <a href="index.html#portfolio">Activities</a>
  143. </li>
  144. <li class="page-scroll">
  145. <a href="index.html#about">About</a>
  146. </li>
  147. <li class="page-scroll">
  148. <a href="index.html#contact">Contact</a>
  149. </li>
  150. </ul>
  151. </div>
  152. <!-- /.navbar-collapse -->
  153. </div>
  154. <!-- /.container-fluid -->
  155. </nav>
  156.  
  157. <!-- Top content -->
  158. <div class="top-content">
  159.  
  160. <div class="inner-bg">
  161. <div class="container">
  162. <div class="row">
  163. <div class="col-sm-8 col-sm-offset-2 text">
  164. <h1>
  165. <font color="White" style="font-size: 1.5em;"><strong>Planbook</strong> Signup Page</font>
  166. </h1>
  167. <div class="description">
  168. <p>
  169. <font color="White" style="font-size:1.5em;" >"To achieve <strong>big</strong> things, start small!"</font>
  170. </p>
  171. </div>
  172.  
  173. <? if (isset($alert)) //if the alert for creating list is set, then echo the alert
  174. {
  175. echo '<div>';
  176. echo $alert;
  177. echo '</div>';
  178. }
  179. ?>
  180.  
  181. </div>
  182.  
  183. <div class="col-sm-6 col-sm-offset-3 form-box">
  184. <div class="form-top">
  185. <div class="form-top-left">
  186. <h3>Sign up for our site</h3>
  187. <p>Making an account is easy and free!</p>
  188. </div>
  189. <div class="form-top-right">
  190. <i class="fa fa-key"></i>
  191. </div>
  192. </div>
  193. <div class="form-bottom">
  194. <form role="form" action="" method="post" class="login-form" id="signup-form">
  195. <div class="form-group">
  196. <label class="sr-only" for="form-username">Username</label>
  197. <input type="text" name="form-username" placeholder="Username..."
  198. class="form-username form-control" id="form-username">
  199. </div>
  200. <div class="form-group">
  201. <label class="sr-only" for="form-password">Password</label>
  202. <input type="password" name="form-password" placeholder="Password..."
  203. class="form-password form-control" id="form-password">
  204. </div>
  205. <div class="form-group">
  206. <label class="sr-only" for="form-repassword">Re-enter Password</label>
  207. <input type="password" name="form-repassword" placeholder="Re-enter password..."
  208. class="form-repassword form-control" id="form-repassword">
  209. </div>
  210. <div class="form-group">
  211. <label class="sr-only" for="form-phonenumber">Phone Number</label>
  212. <input type="text" name="form-phonenumber" placeholder="Phone number..."
  213. class="form-phonenumber form-control" id="form-phonenumber"
  214. onblur="$(this).val($(this).val().replace(/[^0-9.]/g, '')); if($(this).val().length >= 10){$(this).val('(' + $(this).val().substring(0,3) + ') ' + $(this).val().substring(3,6) + '-' + $(this).val().substring(6,10));}">
  215. </div>
  216. <div class="form-group">
  217. <label class="sr-only" for="form-email">Email</label>
  218. <input type="text" name="form-email" placeholder="Email..."
  219. class="form-email form-control" id="form-email">
  220. </div>
  221. <button type="submit" class="btn" >Register!</button>
  222. </form>
  223. <div>
  224.  
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. <div class = "row">
  230. Back to <a href="signin.php">Login</a>
  231. </div>
  232. </div>
  233. </div>
  234.  
  235. </div>
  236.  
  237.  
  238. <!-- Javascript -->
  239. <script src="assets/js/jquery-1.11.1.min.js"></script>
  240. <script src="assets/bootstrap/js/bootstrap.min.js"></script>
  241. <script src="assets/js/jquery.backstretch.min.js"></script>
  242. <script src="assets/js/scripts.js"></script>
  243. <script src="assets/js/formatPhoneInput.js"></script>
  244.  
  245. <!--[if lt IE 10]>
  246. <script src="assets/js/placeholder.js"></script>
  247. <![endif]-->
  248.  
  249. </body>
  250.  
  251. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement