Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "verifyFiles.func.inc.php";
- // require_once "db.func.inc.php";
- ?>
- <!doctype html>
- <html lang="en-US">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>PlayEdge | Homepage Example - 5</title>
- <link rel="shortcut icon" href="favicon.ico">
- <link rel="icon" href="favicon.ico">
- <link rel="stylesheet" type="text/css" href="http://localhost/ab/styles/css/main.css">
- <script type="text/javascript" src="http://localhost/ab/styles/js/base.js"></script>
- <!--[if lt IE 9]>
- <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- </head>
- <body>
- <!--Header-->
- <header>
- <div class="nav">
- <!--Logo-->
- <a class="logo left" href="index.php">
- <h1>free<span>sex</span></h1>
- </a>
- <!--Main Navigation-->
- <ul class="main-nav left">
- <li class="active"><a href="http://localhost/ab/index.php">Home</a></li>
- <li><?php if( isset($_SESSION['userName']) ) { ?>
- <a href="http://localhost/ab/upload.php">Upload</a>
- <?php } else { ?>
- <a href="http://localhost/ab/upload.php">Sign In</a>
- <?php } ?></li>
- <li><?php if( isset($_SESSION['userName']) ) { ?>
- <a href="http://localhost/ab/members/profile.php">Profile</a></li>
- <li><a href="http://localhost/ab/logout.php"> Logout</a></li>
- <?php }
- else {?>
- <a href="register.php">Sign Up</a><?php } ?>
- </li>
- <li><a href="videos.html">Category<span class="is-dd"></span></a>
- <div class="dd-wrapper">
- <div class="dd-container">
- <ul class="dd">
- <?php
- $sql='select * from categories';
- $category=getRows($sql);
- foreach($category as $categry) {
- ?>
- <li><a href="http://localhost/ab/index.php?category=<?php echo $categry['catId']; ?>"><?php echo $categry['category']; ?></a></li><?php } ?>
- </ul>
- </div>
- </div>
- </li>
- </ul>
- <!--User Account-->
- <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>
- </div>
- </div>
- </header>
- <!--Category Tabs-->
- <div id="main">
- <!--Main Content-->
- <div id="content" class="container_24">
- <div class="grid_16">
- <!--Featured Videos-->
- <div class="videos" style="margin-bottom: 15px">
- <header>
- <h3>Members sign up form</h3>
- <div class="v-nav" id="latest-videos_pag"><a href="#"></a></div>
- </header>
- <div class="form">
- <?php
- if( isset($_POST['submitButton'] ) )
- {
- processForm();
- }
- else
- {
- displayForm( array() , array() , array() );
- }
- ?>
- <?php function displayForm( $missingFields , $errorMessages , $arrFields ) { ?>
- <p><i>Fill the following form to become member</i></p>
- <p><b>All fields all compulsory</p>
- <?php
- if( $errorMessages )
- {
- foreach( $errorMessages as $item )
- {
- echo $item;
- }
- }
- var_dump( "before form", $arrFields );
- var_dump( isset( $arrFields['gender'] ) ? setChecked( $arrFields , "gender" , "m" ) : "" );
- ?>
- <form action="" method="post">
- <table>
- <tr>
- <td><label for="username" <?php validateFields( $missingFields , "username" ) ?>>Choose a username</label></td>
- <td><input type="text" name="username" id="username" value="<?php echo !empty( $arrFields['username'] ) ? $arrFields['username'] : "" ?>" ></td>
- </tr>
- <!-- <tr><td> </td></tr> -->
- <tr>
- <td><label for="password1" <?php if($missingFields) echo 'class="error"' ?> >Choose password</label></td>
- <td><input type="password" name="password1" id="password1"></td>
- </tr>
- <tr>
- <td><label for="password2" <?php if($missingFields) echo 'class="error"' ?> >Retype password</label></td>
- <td><input type="password" name="password2" id="password2"></td>
- </tr>
- <tr>
- <td><label for="firstName" <?php validateFields( $missingFields , "firstName" ) ?>>First Name</label></td>
- <td><input type="text" name="firstName" id="firstName" value="<?php echo !empty( $arrFields['firstName'] ) ? $arrFields['firstName'] : "" ?>"></td>
- </tr>
- <tr>
- <td><label for="lastName" <?php validateFields( $missingFields , "lastName" ) ?> >Last Name</label></td>
- <td><input type="text" name="lastName" id="lastName" value="<?php echo !empty( $arrFields['lastName'] ) ? $arrFields['lastName'] : "" ?>"></td>
- </tr>
- <tr>
- <td><label for="email" <?php validateFields( $missingFields , "email" ) ?>>Email Address</label></td>
- <td><input type="text" name="email" id="email" value="<?php echo !empty( $arrFields['email'] ) ? $arrFields['email'] : "" ?>"></td>
- </tr>
- <tr><td><label <?php validateFields( $missingFields , "gender" ) ?>>Your Gender</label></td></tr>
- <tr>
- <td><label for="male">Male</label></td>
- <td><input type="radio" name="gender" id="male" value="m"<?php echo isset( $arrFields['gender'] ) ? setChecked( $arrFields , "gender" , "m" ) : "" ?> ></td>
- </tr>
- <tr>
- <td><label for="female">Female</label></td>
- <td><input type="radio" name="gender" id="female" value="f"<?php echo isset( $arrFields['gender'] ) ? setChecked( $arrFields , "gender" , "f" ) : "" ?> ></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="submitButton" id="submitButton">
- <input type="reset" name="resetButton" id="submitButton"></td>
- </tr>
- </table>
- </form>
- <?php } ?>
- <?php
- function processForm()
- {
- $requiredFields = array( "username" , "firstName" , "lastName" , "password" , "email" , "gender" );
- $missingFields = array();
- $errorMessages = array();
- $arrFields = array(
- "username" => preg_match("/[^a-zA-Z0-9_]/", $_POST['username'] ) ? "" : $_POST['username'] ,
- "password" => (
- !empty( $_POST['password1']) &&
- !empty( $_POST['password2']) &&
- $_POST['password1'] == $_POST['password2'] &&
- !preg_match( "/[^a-zA-Z0-9_!@#$%^&*]/", $_POST['password1'] )
- ) ? $_POST['password1'] : "" ,
- "firstName" => preg_match( "/[^a-zA-Z0-9_]/", $_POST['firstName'] ) ? "" : $_POST['firstName'] ,
- "lastName" => preg_match( "/[^a-zA-Z0-9_]/", $_POST['lastName'] ) ? "" : $_POST['lastName'] ,
- "email" => preg_match_all("/\w+@\w+.\w{2,5}/", $_POST['email'], $matches) ? $_POST['email'] : "" ,
- "gender" => isset( $_POST['gender'] ) ? $_POST['gender'] : ""
- );
- // var_dump($arrFields);
- foreach( $arrFields as $index => $value )
- {
- if( empty( $value ) )
- {
- $missingFields[] = $index;
- }
- }
- // var_dump( "missingFields" , $missingFields);
- if( $missingFields )
- {
- $errorMessages[] = "<p class='error'>There were some errors in filling the form. Correct
- the highlighted fields and re-submit the form</p>";
- }
- $sql = "select username from users where username = \"$_POST[username]\"";
- // var_dump($sql);
- $user = getRows( $sql ) ;
- if( !empty($user) )
- {
- $errorMessages[] = "<p class='error'>Username already exists";
- }
- $sql = "select email from users where email = \"$_POST[email]\"";
- $email = getRows( $sql );
- if( !empty( $email ) )
- {
- $errorMessages[] = "<p class='error'>User with this email Id already exists<p>";
- }
- if( $errorMessages )
- {
- displayForm( $missingFields , $errorMessages , $arrFields );
- }
- else
- {
- $sql = "insert into users(userName , firstName , lastName , gender , email , password )
- values(:userName , :firstName , :lastName , :gender , :email , password(:password ) )";
- insertIntoUsers( $sql , $arrFields );
- header('location: members/');
- exit;
- }
- // exit();
- }
- ?>
- </div>
- <div class="clear"></div>
- </div>
- <div class="clear"></div>
- <div class="clear"></div>
- <hr width='96%'/>
- <div class="clear"></div>
- </div>
- <div class="videos" style="margin-bottom: 15px">
- <header>
- <h3>Latest Videos</h3>
- <div class="v-nav" id="latest-videos_pag"><a href="#"></a></div>
- </header>
- <ul id="latest-videos">
- <?php
- $sql = "select * from videos order by id desc";
- $arrPath = getRows( $sql );
- foreach( $arrPath as $path ) {
- $str = preg_replace( "/video\/video\d+\//", "" , $path['path'] );
- $str = preg_replace("/\//", "", $str);
- ?>
- <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>
- <?php } ?></ul>
- <div class="clear"></div>
- </div>
- <div class="clear"></div>
- <div class="clear"></div>
- </div>
- </div>
- </div>
- <!--Footer-->
- <footer>
- <!--Footer Navigation-->
- <ul class="left">
- <li><a href="index.html">Home</a></li>
- <li><a href="reviews.html">Reviews</a></li>
- <li><a href="videos.html">Videos</a></li>
- <li><a href="coming-soon.html">Community</a></li>
- <li><a href="shortcodes.html">Extras</a></li>
- </ul>
- <!--Copyright-->
- <span class="copyright right">© 2013 PlayEdge.com. All rights reserved.</span> </footer>
- </footer>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement