Advertisement
Guest User

Untitled

a guest
Feb 21st, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.87 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. if (isset($_POST['submitted'])){
  5.  
  6. include('php/connect-mysql.php');
  7. $champ_name= $_POST['champ_name'];
  8. $dojo_name= $_POST['dojo_name'];
  9. $c_email= $_POST['c_email'];
  10. $dojo_add= $_POST['dojo_add'];
  11. $c_pword= $_POST['c_pword'];
  12.  
  13.  
  14. $sqlinsert = "INSERT INTO register (champ_name, dojo_name, c_email, dojo_add, c_pword) VALUES ('$champ_name', '$dojo_name', '$c_email', '$dojo_add', '$c_pword')";
  15.  
  16. // echo 'hey';
  17. // $sqlinsert = "INSERT INTO Ninja (n_name, n_level) VALUES ('$n_name', '$n_level')";
  18.  
  19. if(!mysqli_query($dbcon, $sqlinsert)){
  20. die('error inserting new record');
  21.  
  22. //check for qery if it works!!
  23. }// end of nsted if statement
  24.  
  25. $newrecord= "1 record added to the database!";
  26.  
  27.  
  28. } //end of main if statement
  29.  
  30. ?>
  31.  
  32.  
  33.  
  34. <!DOCTYPE html>
  35. <!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
  36. <!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
  37. <!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
  38. <!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
  39. <head>
  40. <meta charset="utf-8">
  41. <meta charset="utf-8">
  42. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  43. <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
  44. <meta name="description" content="">
  45. <meta name="viewport" content="width=device-width, initial-scale=1">
  46. <title>Login Form</title>
  47. <link rel="stylesheet" href="css/register.css">
  48.  
  49. <link href='http://fonts.googleapis.com/css?family=Raleway:400,100,300,700,600,500' rel='stylesheet' type='text/css'>
  50. <link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic,700' rel='stylesheet' type='text/css'>
  51.  
  52.  
  53.  
  54. <link rel="stylesheet" href="css/slicknav.css">
  55. <link rel="stylesheet" href="css/owl.theme.css">
  56. <link rel="stylesheet" href="css/owl.carousel.css">
  57. <link rel="stylesheet" href="css/owl.transitions.css">
  58. <link rel="stylesheet" href="css/font-awesome.min.css">
  59. <link rel="stylesheet" href="css/bootstrap.min.css">
  60. <link rel="stylesheet" href="css/main.css">
  61. <link rel="stylesheet" href="css/responsive.css">
  62. <script src="js/vendor/modernizr-2.6.2.min.js"></script>
  63.  
  64. <!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  65. </head>
  66. <body>
  67.  
  68. <section id="header">
  69. <div class="container">
  70. <div class="row">
  71. <div class="col-md-6">
  72. <div class="block-left">
  73. <nav class="navbar navbar-default" role="navigation">
  74. <div class="container-fluid">
  75. <!-- Brand and toggle get grouped for better mobile display -->
  76. <div class="navbar-header">
  77. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  78. <span class="sr-only">Toggle navigation</span>
  79. <span class="icon-bar"></span>
  80. <span class="icon-bar"></span>
  81. <span class="icon-bar"></span>
  82. </button>
  83. <div class="nav-logo">
  84. <a href="#"><img src="img/CPA.png" alt="logo" height = "100" width = "150"> </a>
  85. </div>
  86. </div>
  87.  
  88. <!-- Collect the nav links, forms, and other content for toggling -->
  89. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  90. <ul class="nav navbar-nav">
  91. <li class="active"><a href="/CPA"><big><p>Home </big></p><span class="sr-only">(current)</span></a></li>
  92. <li><a href="https://coderdojo.com/"target="_blank"><big><p>CoderDojo</big></p></a></li>
  93. <li><a href="http://kata.coderdojo.com/wiki/Main_Page" target="_blank"><p> <big>Kata</big></p></a></li>
  94.  
  95.  
  96.  
  97.  
  98. <li><a href="log.html"><big><p>Log In</big></p></a></li>
  99. </ul>
  100. </div><!-- /.navbar-collapse -->
  101. </div><!-- /.container-fluid -->
  102. </nav>
  103. </div>
  104. </div><!-- .col-md-6 -->
  105.  
  106. <!-- <div class="col-md-6">
  107. <div class="block-right">
  108. <div class="contact-area">
  109. <ul> -->
  110. <!-- <li><i class="fa fa-phone-square"></i>800-123-456</li> -->
  111. <!-- <li>Need help? Contact: <i class="fa fa-envelope-o"></i>leaveyr@tcd.ie</li>
  112. </ul>
  113. </div>
  114. </div>
  115. </div> --><!-- .col-md-6 close -->
  116. </div><!-- .row close -->
  117. </div><!-- .container close -->
  118. </section><!-- #heder close -->
  119.  
  120.  
  121.  
  122.  
  123. <section class="container">
  124. <div class="register">
  125. <h1>Register</h1>
  126.  
  127. <form method="post" action="register.php">
  128. <input type = "hidden" name="submitted" value="true" />
  129. <!-- <p>Username: </br>
  130. <input id="field_username" title="Username must not be blank and contain only letters, numbers and underscores." type="text" required pattern="\w+" name="username">
  131. </p> -->
  132. <fieldset>
  133. <label> Your Name: </br>
  134. <input type="text" name="champ_name"/>
  135. </label>
  136.  
  137. <label> Dojo Name: </br>
  138. <input type="text" name="dojo_name"/>
  139. </label>
  140.  
  141. <label> Email: </br>
  142. <input type="email" name="c_email">
  143. </label>
  144.  
  145. <label> Dojo's Address: </br>
  146. <input type="text" name="dojo_add"/>
  147. </label>
  148.  
  149. <label> Password: </br>
  150. <input type="password" name="c_pword"/>
  151. </label>
  152.  
  153. <!-- <label> Email: </br>
  154. <input id="email" title="Please enter a valid email." type="text" name="c_email">
  155. </label> -->
  156.  
  157. <!-- <p>Password: </br>
  158. <input id="field_pwd1" title="Password must contain at least 6 characters, including UPPER/lowercase and numbers." type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}" name="pwd1" name="champ_pword"></p> -->
  159. <!-- <p>Confirm Password: </br>
  160. <input id="field_pwd2" title="Please enter the same Password as above." type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}" name="pwd2" name="champ_pword">
  161. </p> -->
  162.  
  163. <!-- <p>Address: </br>
  164. <input id="address" title="Please enter your address" type="text" name="address">
  165. </p>
  166. <p>Dojo Name: </br>
  167. <input id="field_dojoName" title="Please enter the name of your Dojo" type="text" name="dojoName">
  168. </p> -->
  169. </fieldset>
  170.  
  171.  
  172. <!-- <p>
  173. <input type = "submit" name="submitted" value="REGISTER!" >
  174. </p> -->
  175.  
  176. <button type="button" class="btn btn-primary" > <input type="submit" value="Register!"/> </button>
  177.  
  178.  
  179. <!-- <button type="button" class="btn btn-primary" > <input type="submit" value="REGISTER!"/> </button> -->
  180. </form>
  181. <?php
  182. echo $newrecord
  183.  
  184. ?>
  185.  
  186. </div>
  187.  
  188. <div class="register-help">
  189. <p>Already a member? <a href="log.html">Click here to login!</a>.</p>
  190. </div>
  191. </section>
  192.  
  193.  
  194. <script type="text/javascript">
  195.  
  196. document.addEventListener("DOMContentLoaded", function() {
  197.  
  198. // JavaScript form validation
  199.  
  200. var checkPassword = function(str)
  201. {
  202. var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$/;
  203. return re.test(str);
  204. };
  205.  
  206. var checkForm = function(e)
  207. {
  208. if(this.username.value == "") {
  209. alert("Error: Username cannot be blank!");
  210. this.username.focus();
  211. e.preventDefault(); // equivalent to return false
  212. return;
  213. }
  214. re = /^\w+$/;
  215. if(!re.test(this.username.value)) {
  216. alert("Error: Username must contain only letters, numbers and underscores!");
  217. this.username.focus();
  218. e.preventDefault();
  219. return;
  220. }
  221. if(this.pwd1.value != "" && this.pwd1.value == this.pwd2.value) {
  222. if(!checkPassword(this.pwd1.value)) {
  223. alert("The password you have entered is not valid!");
  224. this.pwd1.focus();
  225. e.preventDefault();
  226. return;
  227. }
  228. } else {
  229. alert("Error: Please check that you've entered and confirmed your password!");
  230. this.pwd1.focus();
  231. e.preventDefault();
  232. return;
  233. }
  234. alert("Both username and password are VALID!");
  235. };
  236.  
  237. var myForm = document.getElementById("myForm");
  238. myForm.addEventListener("submit", checkForm, true);
  239.  
  240. // HTML5 form validation
  241.  
  242. var supports_input_validity = function()
  243. {
  244. var i = document.createElement("input");
  245. return "setCustomValidity" in i;
  246. }
  247.  
  248. if(supports_input_validity()) {
  249. var usernameInput = document.getElementById("field_username");
  250. usernameInput.setCustomValidity(usernameInput.title);
  251.  
  252. var pwd1Input = document.getElementById("field_pwd1");
  253. pwd1Input.setCustomValidity(pwd1Input.title);
  254.  
  255. var pwd2Input = document.getElementById("field_pwd2");
  256.  
  257. // var email = document.getElementById("email");
  258. // email.setCustomValidity(email.title);
  259.  
  260. // input key handlers
  261.  
  262. usernameInput.addEventListener("keyup", function() {
  263. usernameInput.setCustomValidity(this.validity.patternMismatch ? usernameInput.title : "");
  264. }, false);
  265.  
  266. pwd1Input.addEventListener("keyup", function() {
  267. this.setCustomValidity(this.validity.patternMismatch ? pwd1Input.title : "");
  268. if(this.checkValidity()) {
  269. pwd2Input.pattern = this.value;
  270. pwd2Input.setCustomValidity(pwd2Input.title);
  271. } else {
  272. pwd2Input.pattern = this.pattern;
  273. pwd2Input.setCustomValidity("");
  274. }
  275. }, false);
  276.  
  277. pwd2Input.addEventListener("keyup", function() {
  278. this.setCustomValidity(this.validity.patternMismatch ? pwd2Input.title : "");
  279. }, false);
  280.  
  281. }
  282.  
  283. }, false);
  284.  
  285. </script>
  286.  
  287. </body>
  288. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement