Advertisement
Crecket

Untitled

Feb 19th, 2015
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.30 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. include('../db_connect.php'); //login data for the database
  5. date_default_timezone_set('Europe/Amsterdam');
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. $con = mysqli_connect($servername, $username, $password, $dbname); 
  10.        
  11. // Check connection
  12. if(isset($_POST['register'])){
  13.    
  14.        
  15.         $testname = mysqli_real_escape_string($con, $_POST['username']);
  16.  
  17.         $testpass = mysqli_real_escape_string($con, $_POST['password']);
  18.  
  19.         $testemail = mysqli_real_escape_string($con, $_POST['email']);
  20.    
  21.         //$ID = mysqli_real_escape_string($con, $_POST['ID']);
  22.    
  23.         $testfirstname = mysqli_real_escape_string($con, $_POST['firstname']);
  24.  
  25.         $testlastname = mysqli_real_escape_string($con, $_POST['lastname']);   
  26.        
  27.         $lastlogin = time();
  28.        
  29.     if ($_POST['username']==''  || $_POST['password']=='' || $_POST['email']==''  || $_POST['firstname']=='' || $_POST['lastname']=='') {
  30.     echo "Please fill in all forms";
  31.     }else{
  32.         if ($conn->connect_error) {
  33.             die("Connection failed.<br>");
  34.         }
  35.         $sql = "SELECT Username, Password, Email, Firstname, Lastname FROM users WHERE Username = '$testname' AND Password = '$testpass' AND Email = '$testemail' AND Firstname = '$testfirstname' AND Lastname = '$testlastname'";
  36.         $result = $conn->query($sql);
  37.         $resultcount = mysqli_num_rows($result);
  38.    
  39.         if ($resultcount == 0) {
  40.             $registered = time();
  41.             $sql = "INSERT INTO users (Username, Password, Email, Firstname, Lastname, Lastlogin, Registered) VALUES ('$testname', '$testpass', '$testemail', '$testfirstname' , '$testlastname', '$lastlogin', '$registered')";
  42.            
  43.             if ($conn->query($sql) === TRUE) {
  44.                 echo "New account created successfully<br>";
  45.             }
  46.        
  47.         }else{
  48.             $row = $result->fetch_assoc();
  49.    
  50.             $query = mysqli_query($con, "SELECT * FROM Email WHERE Email = '".$testemail. "'");
  51.        
  52.  
  53.             if(mysqli_num_rows($query) > 0){
  54.                 echo "Email is already in use.<br>";
  55.             }else{
  56.                 $query = mysqli_query($con, "SELECT * FROM Username WHERE Username = '".$testname. "'");
  57.                 if(mysqli_num_rows(  $query) > 0){
  58.                     echo "Email is already in use.<br>";
  59.                 }else{
  60.                    
  61.                     $sql = "INSERT INTO users (Username, Password, Email, Firstname, Lastname, Lastlogin, Registered) VALUES ('$testname', '$testpass', '$testemail', '$testfirstname' , '$testlastname', '$lastlogin', '$registered')";
  62.                     if ($conn->query($sql) === TRUE) {
  63.                     echo "New account created successfully<br>";
  64.    
  65.                     }
  66.                 }
  67.             }
  68.            
  69.                
  70.    
  71.    
  72.            
  73.            
  74.     //      if ($row["Username"]  == $testname){
  75.     //          echo "Account name is already in use.<br>";
  76.     //      }elseif($row["Email"]  == $testemail){
  77.     //          echo "Email is already in use.<br>";
  78.     //      }else{
  79.     //          $sql = "INSERT INTO users (Username, Password, Email, Firstname, Lastname, Lastlogin) VALUES ('$testname', '$testpass', '$testemail', '$testfirstname' , '$testlastname', '$lastlogin')";
  80.     //          if ($conn->query($sql) === TRUE) {
  81.     //              echo "New account created successfully<br>";
  82.     //          }
  83.     //      }
  84.         }
  85.         $conn->close();
  86.     }
  87.         unset($_POST);
  88.     $_POST = array();
  89.         unset($row);
  90.     $row = array();
  91.         unset($con);
  92.     $con = array();
  93.    
  94. }
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. ?>
  102.  
  103.  
  104.  
  105.  
  106. <!DOCTYPE html>
  107. <html lang="en">
  108.  
  109.  
  110.  
  111.  
  112. <head>
  113.  
  114.     <!-- Webbrowser icon-->
  115.     <link rel="shortcut icon" href="img/site-icon.ico">
  116.  
  117.     <meta charset="utf-8">
  118.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  119.     <meta name="viewport" content="width=device-width, initial-scale=1">
  120.     <meta name="description" content="Simple site by Crecket, has a bunch of videos and coding projects">
  121.     <meta name="keywords" content="Crecketgaming, youtube, battlefield 3, battlefield, call of duty, HTML, CSS, coding, projects, videos">
  122.     <meta name="author" content="Crecketgaming">
  123.  
  124.     <title>Crecketgaming - Register</title>
  125.  
  126.     <!-- Bootstrap Core CSS -->
  127.     <link href="css/bootstrap.min.css" rel="stylesheet">
  128.  
  129.     <!-- Custom CSS -->
  130.     <link href="css/clean-blog.min.css" rel="stylesheet">
  131.  
  132.     <!-- Custom Fonts -->
  133.     <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  134.     <link href='http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
  135.     <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
  136.  
  137.     <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  138.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  139.     <!--[if lt IE 9]>
  140.         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  141.         <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  142.     <![endif]-->
  143.  
  144. </head>
  145.  
  146.  
  147. <body>
  148.  
  149.  
  150.     <!-- Navigation -->
  151.     <nav class="navbar navbar-default navbar-custom navbar-fixed-top">
  152.         <div class="container-fluid">
  153.             <!-- Brand and toggle get grouped for better mobile display -->
  154.             <div class="navbar-header page-scroll">
  155.                 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  156.                     <span class="sr-only">Toggle navigation</span>
  157.                     <span class="icon-bar"></span>
  158.                     <span class="icon-bar"></span>
  159.                     <span class="icon-bar"></span>
  160.                 </button>
  161.                
  162.             </div>
  163.  
  164.              <!-- Collect the nav links, forms, and other content for toggling -->
  165.             <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  166.                 <ul class="nav navbar-nav navbar-right">
  167.                     <li>
  168.                         <a href="index">Home</a>
  169.                     </li>
  170.    
  171.                      <li>
  172.                         <a href="vbprojects">Coding projects</a>
  173.                         <ul>       
  174.                                 <li><a href="spel1/index">Tic Tac Toe (dutch)</a></li>
  175.                                 <li><a href="vbprojects">Visualbasic Projects</a></li>
  176.                                 <li><a href="calculator">Calculator</a></li>
  177.                         </ul>
  178.                      </li>
  179.                    
  180.                     <li>
  181.                          <a href="teamspeak">Teamspeak</a>
  182.                     </li>
  183.                    
  184.                     <li>
  185.                         <a href="youtube">Youtube</a>
  186.                     </li>
  187.                     <li>
  188.                        <a href="games">Games</a>
  189.                         <ul>       
  190.                                 <li><a href="battlefield">Battlefield</a></li>
  191.                                 <li><a href="league">League of Legends</a></li>
  192.                         </ul>
  193.                     </li>
  194.                     <li>
  195.                         <a href="login">Login</a>
  196.                         <ul>       
  197.                                 <li><a href="register">Register</a></li>
  198.                         </ul>
  199.                     </li>
  200.                 </ul>
  201.             </div>
  202.             <!-- /.navbar-collapse -->
  203.         </div>
  204.         <!-- /.container -->
  205.     </nav>
  206.  
  207.     <!-- Page Header -->
  208.     <!-- Set your background image for this header on the line below. -->
  209.     <header class="intro-header" style="background-image: url('img/home-bg.jpg')">
  210.         <div class="container">
  211.             <div class="row">
  212.                 <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
  213.                     <div class="site-heading">
  214.                         <h1>Crecketgaming</h1>
  215.                         <hr class="small">
  216.                         <span class="subheading">Register to Crecketgaming - Under construction</span>
  217.                     </div>
  218.                 </div>
  219.             </div>
  220.         </div>
  221.     </header>
  222.  
  223.     <!-- Main Content -->
  224.     <div class="container">
  225.         <div class="row">
  226.             <div align="center" class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
  227.                
  228.             <form method="post" action="register.php" >
  229.                 <table style='padding: 0px;'>
  230.                 <tr>
  231.                     <td class="login"><p >Username:</p></td><td class="login"> <input maxlength="32" type="text" name="username"><br></td>
  232.                 </tr>
  233.                 <tr>
  234.                     <td class="login" ><p >Password:</p></td><td class="login"> <input maxlength="32" type="password" name="password"><br></td>
  235.                 </tr>
  236.                 <tr>
  237.                     <td class="login"><p >First name:</p></td><td class="login"> <input maxlength="32" type="text" name="firstname"><br></td>
  238.                 </tr>
  239.                                 <tr>
  240.                     <td class="login"><p >Last name:</p></td><td class="login"> <input maxlength="32" type="text" name="lastname"><br></td>
  241.                 </tr>
  242.                                 <tr>
  243.                     <td class="login"><p >Email address:</p></td><td class="login"> <input maxlength="50"  type="email" name="email"><br></td>
  244.                 </tr>
  245.                 <tr>
  246.                     <td class="login"><p style='float:left;'>Remember Me:</p><input style='float:left; margin-top:40px; margin-left:40px;' type="checkbox" name="rememberme" value="1"><br>
  247.                     </td >
  248.                     <td class="login" align="center" >
  249.                     <input class="btnlogin" type="submit" name="register" value="Register"></td>
  250.                 </tr>
  251.                 </table>
  252.                
  253.             </form>
  254.                
  255.         </div>
  256.     </div>
  257. <div>
  258.  
  259.     <hr>
  260.  
  261.     <!-- Footer -->
  262. <footer>
  263.         <div class="container">
  264.             <div class="row">
  265.                 <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
  266.                     <ul class="list-inline text-center">
  267.                         <li>
  268.                             <a href="https://www.youtube.com/user/CrecketGaming"><img src="img/youtube-icon.jpg"></a>
  269.                         </li>
  270.                      
  271.                       </ul>
  272.                     <p class="copyright text-muted">Copyright &copy; Crecketgaming 2015</p>
  273.                    
  274.                 </div>
  275.             </div>
  276.         </div>
  277.     </footer>
  278.  
  279.     <!-- jQuery -->
  280.     <script src="js/jquery.js"></script>
  281.  
  282.     <!-- Bootstrap Core JavaScript -->
  283.     <script src="js/bootstrap.min.js"></script>
  284.  
  285.     <!-- Custom Theme JavaScript -->
  286.     <script src="js/clean-blog.min.js"></script>
  287.  
  288.         <!-- Start of StatCounter Code for Default Guide -->
  289. <script type="text/javascript">
  290. var sc_project=10296953;
  291. var sc_invisible=1;
  292. var sc_security="011cd460";
  293. var scJsHost = (("https:" == document.location.protocol) ?
  294. "https://secure." : "http://www.");
  295. document.write("<sc"+"ript type='text/javascript' src='" +
  296. scJsHost+
  297. "statcounter.com/counter/counter.js'></"+"script>");
  298. </script>
  299. <noscript><div class="statcounter"><a title="hit counter"
  300. href="http://statcounter.com/" target="_blank"><img
  301. class="statcounter"
  302. src="http://c.statcounter.com/10296953/0/011cd460/1/"
  303. alt="hit counter"></a></div></noscript>
  304. <!-- End of StatCounter Code for Default Guide -->
  305.    
  306.    
  307. </body>
  308.  
  309. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement