Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. <?php
  2.  
  3. ob_start();
  4.  
  5. if(file_exists("install.php") == "1"){
  6. header('Location: install.php');
  7. exit();
  8. }
  9.  
  10. include 'inc/database.php';
  11.  
  12. $result = mysqli_query($con, "SELECT * FROM `settings` LIMIT 1") or die(mysqli_error($con));
  13. while($row = mysqli_fetch_assoc($result)){
  14. $website = $row['website'];
  15. $favicon = $row['favicon'];
  16. }
  17.  
  18. if (!isset($_SESSION)) {
  19. session_start();
  20. }
  21.  
  22. if (isset($_SESSION['username'])) {
  23. header('Location: index.php');
  24. exit();
  25. }
  26.  
  27. if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirmpassword']) && isset($_POST['email'])){
  28.  
  29. $username = mysqli_real_escape_string($con, $_POST['username']);
  30. $password = mysqli_real_escape_string($con, md5($_POST['password']));
  31. $confirmpassword = mysqli_real_escape_string($con, md5($_POST['confirmpassword']));
  32. $email = mysqli_real_escape_string($con, $_POST['email']);
  33. $capt = mysqli_real_escape_string($con, $_POST['capt']);
  34. $ip = mysqli_real_escape_string($con, $_SERVER['REMOTE_ADDR']);
  35. $date = date('Y-m-d');
  36.  
  37.  
  38. if($password != $confirmpassword){
  39. die("The confirmation password was not equal to the password.");
  40. }
  41.  
  42. if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  43. die("The email entered was not correct.");
  44. }
  45.  
  46. $result = mysqli_query($con, "SELECT * FROM `users` WHERE `username` = '$username'") or die(mysqli_error($con));
  47. if(mysqli_num_rows($result) > 0){
  48. die("This username already exists.");
  49. }
  50.  
  51. $result = mysqli_query($con, "SELECT * FROM `users` WHERE `ip` = '$ip'") or die(mysqli_error($con));
  52. if(mysqli_num_rows($result) > 0){
  53. die("This IP already exists.");
  54. }
  55.  
  56. $result = mysqli_query($con, "SELECT * FROM `users` WHERE `email` = '$email'") or die(mysqli_error($con));
  57. if(mysqli_num_rows($result) > 0){
  58. die("This email already exists.");
  59. }
  60.  
  61.  
  62.  
  63. mysqli_query($con, "INSERT INTO `users` (`username`, `password`, `email`, `date`, `ip`) VALUES ('$username', '$password', '$email', '$date', '$ip')") or die(mysqli_error($con));
  64.  
  65. header("Location: login.php?action=registered");
  66.  
  67. }
  68.  
  69. ?>
  70.  
  71. <!DOCTYPE html>
  72. <html lang="en">
  73. <head>
  74. <meta charset="utf-8">
  75. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  76. <meta name="description" content="">
  77. <meta name="author" content="24/7">
  78. <meta name="keyword" content="">
  79. <link rel="shortcut icon" href="<?php echo $favicon;?>">
  80.  
  81. <title><?php echo $website;?> - Registration</title>
  82.  
  83. <!-- Bootstrap core CSS -->
  84. <link href="css/bootstrap.min.css" rel="stylesheet">
  85. <link href="css/bootstrap-reset.css" rel="stylesheet">
  86. <!-- Custom styles for this template -->
  87. <link href="css/style.css" rel="stylesheet">
  88. <link href="css/style-responsive.css" rel="stylesheet" />
  89.  
  90. <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
  91. <!--[if lt IE 9]>
  92. <script src="js/html5shiv.js"></script>
  93. <script src="js/respond.min.js"></script>
  94. <![endif]-->
  95.  
  96. </head>
  97.  
  98. <body class="login-body">
  99.  
  100. <div class="container">
  101.  
  102. <form class="form-signin" action="register.php" method="POST">
  103. <h2 class="form-signin-heading"><?php echo $website;?></h2>
  104. <div class="login-wrap">
  105. <input type="text" id="username" name="username" class="form-control" placeholder="Username" autofocus>
  106. <input type="password" id="password" name="password" class="form-control" placeholder="Password">
  107. <input type="password" id="confirmpassword" name="confirmpassword" class="form-control" placeholder="Confirm Password">
  108. <input type="text" id="email" name="email" class="form-control" placeholder="Email">
  109. <button class="btn btn-lg btn-login btn-block" type="submit">Register</button>
  110. </form>
  111.  
  112. <div class="registration">
  113. Already have an account?&nbsp
  114. <a class="" href="login.php">
  115. Sign In
  116. </a>
  117. </div>
  118.  
  119. </div>
  120.  
  121. </div>
  122.  
  123.  
  124.  
  125. <!-- js placed at the end of the document so the pages load faster -->
  126. <script src="js/jquery.js"></script>
  127. <script src="js/bootstrap.min.js"></script>
  128.  
  129. </body>
  130. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement