Advertisement
Achilles

Untitled

Jul 5th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.60 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. require_once "verifyFiles.func.inc.php";
  5. // require_once "db.func.inc.php";
  6.  
  7. ?>
  8.  
  9. <!doctype html>
  10. <html lang="en-US">
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  13. <title>PlayEdge | Homepage Example - 5</title>
  14. <link rel="shortcut icon" href="favicon.ico">
  15. <link rel="icon" href="favicon.ico">
  16. <link rel="stylesheet" type="text/css" href="http://localhost/ab/styles/css/main.css">
  17. <script type="text/javascript" src="http://localhost/ab/styles/js/base.js"></script>
  18. <!--[if lt IE 9]>
  19. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  20. <![endif]-->
  21. </head>
  22. <body>
  23. <!--Header-->
  24. <header>
  25. <div class="nav">
  26. <!--Logo-->
  27. <a class="logo left" href="index.php">
  28. <h1>free<span>sex</span></h1>
  29. </a>
  30. <!--Main Navigation-->
  31. <ul class="main-nav left">
  32. <li class="active"><a href="http://localhost/ab/index.php">Home</a></li>
  33. <li><?php if( isset($_SESSION['userName']) ) { ?>
  34. <a href="http://localhost/ab/upload.php">Upload</a>
  35. <?php } else { ?>
  36. <a href="http://localhost/ab/upload.php">Sign In</a>
  37. <?php } ?></li>
  38. <li><?php if( isset($_SESSION['userName']) ) { ?>
  39. <a href="http://localhost/ab/members/profile.php">Profile</a></li>
  40. <li><a href="http://localhost/ab/logout.php"> Logout</a></li>
  41. <?php }
  42. else {?>
  43. <a href="register.php">Sign Up</a><?php } ?>
  44. </li>
  45. <li><a href="videos.html">Category<span class="is-dd"></span></a>
  46. <div class="dd-wrapper">
  47. <div class="dd-container">
  48. <ul class="dd">
  49. <?php
  50.  
  51. $sql='select * from categories';
  52. $category=getRows($sql);
  53.  
  54. foreach($category as $categry) {
  55.  
  56. ?>
  57.  
  58. <li><a href="http://localhost/ab/index.php?category=<?php echo $categry['catId']; ?>"><?php echo $categry['category']; ?></a></li><?php } ?>
  59. </ul>
  60. </div>
  61. </div>
  62. </li>
  63. </ul>
  64. <!--User Account-->
  65. <div class="user-profile right" id="profile"> <img class="avatar" src="http://placehold.it/28x28.jpg" alt="image title" /> <span class="is-dd"><?php if(isset($_SESSION['userName']))echo $_SESSION['userName']; else echo 'Guest'; ?></span>
  66. </div>
  67.  
  68. </div>
  69. </header>
  70. <!--Category Tabs-->
  71. <div id="main">
  72. <!--Main Content-->
  73. <div id="content" class="container_24">
  74. <div class="grid_16">
  75. <!--Featured Videos-->
  76. <div class="videos" style="margin-bottom: 15px">
  77. <header>
  78. <h3>Members sign up form</h3>
  79. <div class="v-nav" id="latest-videos_pag"><a href="#"></a></div>
  80. </header>
  81. <div class="form">
  82. <?php
  83.  
  84. if( isset($_POST['submitButton'] ) )
  85. {
  86. processForm();
  87. }
  88.  
  89. else
  90. {
  91. displayForm( array() , array() , array() );
  92. }
  93.  
  94. ?>
  95.  
  96.  
  97. <?php function displayForm( $missingFields , $errorMessages , $arrFields ) { ?>
  98.  
  99. <p><i>Fill the following form to become member</i></p>
  100. <p><b>All fields all compulsory</p>
  101.  
  102. <?php
  103.  
  104. if( $errorMessages )
  105. {
  106. foreach( $errorMessages as $item )
  107. {
  108. echo $item;
  109. }
  110. }
  111.  
  112. var_dump( "before form", $arrFields );
  113.  
  114. var_dump( isset( $arrFields['gender'] ) ? setChecked( $arrFields , "gender" , "m" ) : "" );
  115.  
  116. ?>
  117.  
  118. <form action="" method="post">
  119. <table>
  120. <tr>
  121. <td><label for="username" <?php validateFields( $missingFields , "username" ) ?>>Choose a username</label></td>
  122. <td><input type="text" name="username" id="username" value="<?php echo !empty( $arrFields['username'] ) ? $arrFields['username'] : "" ?>" ></td>
  123. </tr>
  124.  
  125. <!-- <tr><td>&nbsp;</td></tr> -->
  126.  
  127. <tr>
  128. <td><label for="password1" <?php if($missingFields) echo 'class="error"' ?> >Choose password</label></td>
  129. <td><input type="password" name="password1" id="password1"></td>
  130. </tr>
  131.  
  132. <tr>
  133. <td><label for="password2" <?php if($missingFields) echo 'class="error"' ?> >Retype password</label></td>
  134. <td><input type="password" name="password2" id="password2"></td>
  135. </tr>
  136.  
  137. <tr>
  138. <td><label for="firstName" <?php validateFields( $missingFields , "firstName" ) ?>>First Name</label></td>
  139. <td><input type="text" name="firstName" id="firstName" value="<?php echo !empty( $arrFields['firstName'] ) ? $arrFields['firstName'] : "" ?>"></td>
  140. </tr>
  141.  
  142. <tr>
  143. <td><label for="lastName" <?php validateFields( $missingFields , "lastName" ) ?> >Last Name</label></td>
  144. <td><input type="text" name="lastName" id="lastName" value="<?php echo !empty( $arrFields['lastName'] ) ? $arrFields['lastName'] : "" ?>"></td>
  145. </tr>
  146.  
  147. <tr>
  148. <td><label for="email" <?php validateFields( $missingFields , "email" ) ?>>Email Address</label></td>
  149. <td><input type="text" name="email" id="email" value="<?php echo !empty( $arrFields['email'] ) ? $arrFields['email'] : "" ?>"></td>
  150. </tr>
  151.  
  152. <tr><td><label <?php validateFields( $missingFields , "gender" ) ?>>Your Gender</label></td></tr>
  153.  
  154. <tr>
  155. <td><label for="male">Male</label></td>
  156. <td><input type="radio" name="gender" id="male" value="m"<?php echo isset( $arrFields['gender'] ) ? setChecked( $arrFields , "gender" , "m" ) : "" ?> ></td>
  157. </tr>
  158.  
  159. <tr>
  160. <td><label for="female">Female</label></td>
  161. <td><input type="radio" name="gender" id="female" value="f"<?php echo isset( $arrFields['gender'] ) ? setChecked( $arrFields , "gender" , "f" ) : "" ?> ></td>
  162. </tr>
  163.  
  164. <tr>
  165. <td></td>
  166. <td><input type="submit" name="submitButton" id="submitButton">
  167. <input type="reset" name="resetButton" id="submitButton"></td>
  168. </tr>
  169.  
  170. </table>
  171. </form>
  172.  
  173.  
  174. <?php } ?>
  175.  
  176. <?php
  177.  
  178. function processForm()
  179. {
  180. $requiredFields = array( "username" , "firstName" , "lastName" , "password" , "email" , "gender" );
  181. $missingFields = array();
  182. $errorMessages = array();
  183.  
  184. $arrFields = array(
  185.  
  186. "username" => preg_match("/[^a-zA-Z0-9_]/", $_POST['username'] ) ? "" : $_POST['username'] ,
  187.  
  188. "password" => (
  189. !empty( $_POST['password1']) &&
  190. !empty( $_POST['password2']) &&
  191. $_POST['password1'] == $_POST['password2'] &&
  192. !preg_match( "/[^a-zA-Z0-9_!@#$%^&*]/", $_POST['password1'] )
  193. ) ? $_POST['password1'] : "" ,
  194.  
  195.  
  196. "firstName" => preg_match( "/[^a-zA-Z0-9_]/", $_POST['firstName'] ) ? "" : $_POST['firstName'] ,
  197.  
  198. "lastName" => preg_match( "/[^a-zA-Z0-9_]/", $_POST['lastName'] ) ? "" : $_POST['lastName'] ,
  199.  
  200. "email" => preg_match_all("/\w+@\w+.\w{2,5}/", $_POST['email'], $matches) ? $_POST['email'] : "" ,
  201.  
  202. "gender" => isset( $_POST['gender'] ) ? $_POST['gender'] : ""
  203.  
  204. );
  205.  
  206.  
  207. // var_dump($arrFields);
  208.  
  209. foreach( $arrFields as $index => $value )
  210. {
  211. if( empty( $value ) )
  212. {
  213. $missingFields[] = $index;
  214. }
  215. }
  216.  
  217. // var_dump( "missingFields" , $missingFields);
  218.  
  219. if( $missingFields )
  220. {
  221. $errorMessages[] = "<p class='error'>There were some errors in filling the form. Correct
  222. the highlighted fields and re-submit the form</p>";
  223. }
  224.  
  225. $sql = "select username from users where username = \"$_POST[username]\"";
  226.  
  227. // var_dump($sql);
  228.  
  229. $user = getRows( $sql ) ;
  230.  
  231. if( !empty($user) )
  232. {
  233. $errorMessages[] = "<p class='error'>Username already exists";
  234. }
  235.  
  236. $sql = "select email from users where email = \"$_POST[email]\"";
  237.  
  238. $email = getRows( $sql );
  239.  
  240. if( !empty( $email ) )
  241. {
  242. $errorMessages[] = "<p class='error'>User with this email Id already exists<p>";
  243. }
  244.  
  245.  
  246. if( $errorMessages )
  247. {
  248. displayForm( $missingFields , $errorMessages , $arrFields );
  249. }
  250.  
  251. else
  252. {
  253. $sql = "insert into users(userName , firstName , lastName , gender , email , password )
  254. values(:userName , :firstName , :lastName , :gender , :email , password(:password ) )";
  255.  
  256. insertIntoUsers( $sql , $arrFields );
  257. header('location: members/');
  258. exit;
  259.  
  260. }
  261.  
  262. // exit();
  263. }
  264.  
  265. ?>
  266. </div>
  267. <div class="clear"></div>
  268. </div>
  269.  
  270. <div class="clear"></div>
  271. <div class="clear"></div>
  272.  
  273.  
  274.  
  275. <hr width='96%'/>
  276.  
  277. <div class="clear"></div>
  278. </div>
  279. <div class="videos" style="margin-bottom: 15px">
  280. <header>
  281. <h3>Latest Videos</h3>
  282. <div class="v-nav" id="latest-videos_pag"><a href="#"></a></div>
  283. </header>
  284. <ul id="latest-videos">
  285. <?php
  286. $sql = "select * from videos order by id desc";
  287. $arrPath = getRows( $sql );
  288. foreach( $arrPath as $path ) {
  289. $str = preg_replace( "/video\/video\d+\//", "" , $path['path'] );
  290. $str = preg_replace("/\//", "", $str);
  291. ?>
  292. <li><a href="<?php echo 'http://localhost/ab/'.$path['path'] ?>"><img src="<?php echo 'http://localhost/ab/'.$path['path'] . $str . ".jpg" ?>" width='200px' height='152px' alt="image title" /><span class="play-video"></span><span class="description">Last of Us Trailer</span></a></li>
  293. <?php } ?></ul>
  294. <div class="clear"></div>
  295. </div>
  296.  
  297. <div class="clear"></div>
  298. <div class="clear"></div>
  299. </div>
  300. </div>
  301. </div>
  302. <!--Footer-->
  303. <footer>
  304. <!--Footer Navigation-->
  305. <ul class="left">
  306. <li><a href="index.html">Home</a></li>
  307. <li><a href="reviews.html">Reviews</a></li>
  308. <li><a href="videos.html">Videos</a></li>
  309. <li><a href="coming-soon.html">Community</a></li>
  310. <li><a href="shortcodes.html">Extras</a></li>
  311. </ul>
  312.  
  313. <!--Copyright-->
  314. <span class="copyright right">&copy; 2013 PlayEdge.com. All rights reserved.</span> </footer>
  315. </footer>
  316. </body>
  317. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement