Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.01 KB | None | 0 0
  1. <?php
  2.  
  3. // If the form was submitted, scrub the input (server-side validation)
  4. // see below in the html for the client-side validation using jQuery
  5.  
  6. $username = '';
  7. $password = '';
  8. $address = '';
  9. $email = '';
  10. $phone = '';
  11. $output = '';
  12.  
  13. /* Set oracle user login and password info */
  14. $dbuser = "jccrawfo"; /* your deakin login */
  15. $dbpass = "password"; /* your deakin password */
  16. $db = "SSID";
  17. $connect = OCILogon($dbuser, $dbpass, $db);
  18.  
  19. if($_POST) {
  20. // collect all input and trim to remove leading and trailing whitespaces
  21. $username = trim($_POST['username']);
  22. $password = trim($_POST['password']);
  23. $email = trim($_POST['email']);
  24. $phone = trim($_POST['phone']);
  25. $city = trim($_POST['company']);
  26. $address = trim($_POST['address']);
  27.  
  28. $errors = array();
  29.  
  30. // Validate the input
  31. if (strlen($username) == 0){
  32. array_push($errors, "Please enter your name");
  33. }
  34. if (strlen($password) < 6){
  35. array_push($errors, "Please enter a password. Passwords must contain at least 6 characters.");
  36. }
  37. if (strlen($address) == 0) {
  38. array_push($errors, "Please specify your address");
  39. }
  40. //if (!filter_var($email, FILTER_VALIDATE_EMAIL))
  41. //array_push($errors, "Please specify a valid email address");
  42.  
  43. if (strlen($phone) == 0){
  44. array_push($errors, "Please enter a valid phone number");
  45.  
  46. }
  47.  
  48. // If no errors were found, proceed with storing the user input
  49. if (count($errors) == 0) {
  50. array_push($errors, "No errors were found. Thanks!");
  51. if (!$connect) {
  52. echo "An error occurred connecting to the database";
  53. exit;
  54. }
  55.  
  56.  
  57. // build INSERT query
  58. $query = "INSERT INTO account ( ID, username, password, email, Phone, address ) VALUES ( user_seq.nextval, '$username', '$password', '$email', '$phone', '$address' );";
  59.  
  60. //echo "$query";
  61.  
  62.  
  63. /* check the sql statement for errors and if errors report them */
  64. $stmt = OCIParse($connect, $query);
  65. //echo "SQL: $query<br>";
  66. if(!$stmt) {
  67. echo "An error occurred in parsing the sql string.\n";
  68. exit;
  69. }
  70. oci_execute($stmt);
  71. }
  72.  
  73. //Prepare errors for output
  74. $output = '';
  75. foreach($errors as $val) {
  76. $output .= "<p class='output'>$val</p>";
  77. }
  78.  
  79. }
  80.  
  81. ?>
  82.  
  83.  
  84. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  85. <html xmlns="http://www.w3.org/1999/xhtml">
  86. <head>
  87. <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  88. <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
  89.  
  90. <!-- jQuery Form Validation code -->
  91. <script>
  92.  
  93. // When the browser is ready...
  94. $(function() {
  95.  
  96. // Setup form validation on the #register-form element
  97. $("#register").validate({
  98.  
  99. // Specify the validation rules
  100. rules: {
  101. name: "required",
  102. phone: "required",
  103. address: "required",
  104. email: {
  105. required: true,
  106. email: true
  107. },
  108. username: "required",
  109. password: {
  110. required: true,
  111. minlength: 6
  112. }
  113. },
  114.  
  115. // Specify the validation error messages
  116. messages: {
  117. name: "Please enter your name",
  118. phone: "Please specify your phone number",
  119. address: "Please enter your address",
  120. email: "Please enter a valid email address",
  121. username: "Please enter a valid username",
  122. password: {
  123. required: "Please provide a password",
  124. minlength: "Your password must be at least 5 characters long"
  125. }
  126. },
  127.  
  128. submitHandler: function(form) {
  129. form.submit();
  130. }
  131. });
  132.  
  133. });
  134.  
  135. </script>
  136. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
  137. <title>Pet Shop</title>
  138. <link rel="stylesheet" type="text/css" href="style.css" />
  139. </head>
  140. <body>
  141. <div id="wrap">
  142.  
  143. <div class="header">
  144. <div class="logo"><a href="index.html"><img src="images/logo.gif" alt="" title="" border="0" /></a></div>
  145. <div id="menu">
  146. <ul>
  147. <li><a href="index.html">home</a></li>
  148. <li><a href="about.html">about us</a></li>
  149. <li><a href="category.xml">category</a></li>
  150. <li><a href="specials.html">specials</a></li>
  151. <li><a href="details.html">details</a></li>
  152. <li><a href="myaccount.html">my accout</a></li>
  153. <li class="selected"><a href="register.html">register</a></li>
  154. <li><a href="contact.html">contact</a></li>
  155. </ul>
  156. </div>
  157.  
  158.  
  159. </div>
  160.  
  161.  
  162. <div class="center_content">
  163. <div class="left_content">
  164. <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>Register</div>
  165.  
  166. <div class="feat_prod_box_details">
  167. <p class="details">
  168. Register a new account to buy our products!
  169. <?php echo $output; ?>
  170. </p>
  171.  
  172. <div class="contact_form">
  173. <div class="form_subtitle">create new account</div>
  174. <form action="register.php" id="register" method="post">
  175. <div class="form_row">
  176. <label class="contact"><strong>Username:</strong></label>
  177. <input type="text" name="username" class="contact_input" />
  178. </div>
  179.  
  180.  
  181. <div class="form_row">
  182. <label class="contact"><strong>Password:</strong></label>
  183. <input type="text" name="password" class="contact_input" />
  184. </div>
  185.  
  186. <div class="form_row">
  187. <label class="contact"><strong>Email:</strong></label>
  188. <input type="text" name="email" class="contact_input" />
  189. </div>
  190.  
  191.  
  192. <div class="form_row">
  193. <label class="contact"><strong>Phone(with area code):</strong></label>
  194. <input type="text" name="phone" class="contact_input" />
  195. </div>
  196.  
  197. <div class="form_row">
  198. <label class="contact"><strong>Address:</strong></label>
  199. <input type="text" name="address" class="contact_input" />
  200. </div>
  201.  
  202. <div class="form_row">
  203. <label class="contact"><strong>City:</strong></label>
  204. <input type="text" name="address" class="contact_input" />
  205. </div>
  206.  
  207. <div class="form_row">
  208. <div class="terms">
  209. <input type="checkbox" name="terms" />
  210. I agree to the <a href="#">terms &amp; conditions</a> </div>
  211. </div>
  212.  
  213.  
  214. <div class="form_row">
  215. <input type="submit" class="register" value="register" />
  216. </div>
  217. </form>
  218. </div>
  219.  
  220. </div>
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. <div class="clear"></div>
  228. </div><!--end of left content-->
  229.  
  230. <div class="right_content">
  231.  
  232. <div class="languages_box">
  233. <span class="red">Languages:</span>
  234. <a href="#"><img src="images/au.gif" alt="" title="" border="0" height="12px" width="15px"/></a>
  235. <!-- commented out by Shang 10/07/2014
  236. <a href="#"><img src="images/gb.gif" alt="" title="" border="0" /></a>
  237. <a href="#"><img src="images/fr.gif" alt="" title="" border="0" /></a>
  238. <a href="#"><img src="images/de.gif" alt="" title="" border="0" /></a>
  239. -->
  240. </div>
  241.  
  242. <div class="currency">
  243. <span class="red">Currency: </span>
  244. <!-- commented by shang 10/07/2014
  245. <a href="#">GBP</a>
  246. <a href="#">EUR</a> -->
  247. <a href="#" class="selected">AUD</a>
  248. </div>
  249.  
  250.  
  251. <div class="cart">
  252. <div class="title"><span class="title_icon"><img src="images/cart.gif" alt="" title="" /></span>My cart</div>
  253. <div class="home_cart_content">
  254. 3 x items | <span class="red">TOTAL: 100$</span>
  255. </div>
  256. <a href="cart.html" class="view_cart">view cart</a>
  257.  
  258. </div>
  259.  
  260. <div class="title"><span class="title_icon"><img src="images/bullet3.gif" alt="" title="" /></span>About Our Shop</div>
  261. <div class="about">
  262. <p>
  263. <img src="images/about.gif" alt="" title="" class="right" />
  264. Pet Shop is an Australian owned & operated pet store that stocks a range of pets and accessories in Geelong. Our online store sells a large selection of dogs, cats, birds and beetles. Make our Pet Shop your first choice for pets!
  265. </p>
  266.  
  267. </div>
  268.  
  269. <div class="right_box">
  270.  
  271. <div class="title"><span class="title_icon"><img src="images/bullet4.gif" alt="" title="" /></span>Promotions</div>
  272. <div class="new_prod_box">
  273. <a href="details.html">product name</a>
  274. <div class="new_prod_bg">
  275. <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
  276. <a href="details.html"><img src="images/thumb1.gif" alt="" title="" class="thumb" border="0" /></a>
  277. </div>
  278. </div>
  279.  
  280. <div class="new_prod_box">
  281. <a href="details.html">product name</a>
  282. <div class="new_prod_bg">
  283. <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
  284. <a href="details.html"><img src="images/thumb2.gif" alt="" title="" class="thumb" border="0" /></a>
  285. </div>
  286. </div>
  287.  
  288. <div class="new_prod_box">
  289. <a href="details.html">product name</a>
  290. <div class="new_prod_bg">
  291. <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
  292. <a href="details.html"><img src="images/thumb3.gif" alt="" title="" class="thumb" border="0" /></a>
  293. </div>
  294. </div>
  295.  
  296. </div>
  297.  
  298. <div class="right_box">
  299.  
  300. <div class="title"><span class="title_icon"><img src="images/bullet5.gif" alt="" title="" /></span>Categories</div>
  301.  
  302. <ul class="list">
  303. <li><a href="#">accesories</a></li>
  304. <li><a href="#">pets gifts</a></li>
  305. <li><a href="#">specials</a></li>
  306. <li><a href="#">hollidays gifts</a></li>
  307. <li><a href="#">accesories</a></li>
  308. <li><a href="#">pets gifts</a></li>
  309. <li><a href="#">specials</a></li>
  310. <li><a href="#">hollidays gifts</a></li>
  311. <li><a href="#">accesories</a></li>
  312. <li><a href="#">pets gifts</a></li>
  313. <li><a href="#">specials</a></li>
  314. </ul>
  315.  
  316. <!-- commented out by Shang 10/07/2014
  317. <div class="title"><span class="title_icon"><img src="images/bullet6.gif" alt="" title="" /></span>Partners</div>
  318.  
  319. <ul class="list">
  320. <li><a href="#">accesories</a></li>
  321. <li><a href="#">pets gifts</a></li>
  322. <li><a href="#">specials</a></li>
  323. <li><a href="#">hollidays gifts</a></li>
  324. <li><a href="#">accesories</a></li>
  325. <li><a href="#">pets gifts</a></li>
  326. <li><a href="#">specials</a></li>
  327. <li><a href="#">hollidays gifts</a></li>
  328. <li><a href="#">accesories</a></li>
  329. </ul>
  330.  
  331. -->
  332.  
  333. </div>
  334.  
  335.  
  336. </div><!--end of right content-->
  337.  
  338.  
  339.  
  340.  
  341. <div class="clear"></div>
  342. </div><!--end of center content-->
  343.  
  344.  
  345. <div class="footer">
  346. <div class="left_footer"><img src="images/footer_logo.gif" alt="" title="" /><br /> <a href="http://csscreme.com/freecsstemplates/" title="free css templates"><img src="images/csscreme.gif" alt="free css templates" border="0" /></a></div>
  347. <div class="right_footer">
  348. <a href="#">home</a>
  349. <a href="#">about us</a>
  350. <a href="#">services</a>
  351. <a href="#">privacy policy</a>
  352. <a href="#">contact us</a>
  353.  
  354. </div>
  355.  
  356.  
  357. </div>
  358. <p>"©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT203: Web Programming. Therefore it is not part of the University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY."</p>
  359.  
  360.  
  361. </div>
  362.  
  363. </body>
  364. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement