Advertisement
Guest User

Untitled

a guest
Mar 14th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once('dbconfig/config.php');
  4. //phpinfo();
  5. ?>
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <title>Sign Up Page</title>
  10. <link rel="stylesheet" href="css/registeradmin.css">
  11. </head>
  12. <body>
  13. <div id="main-wrapper">
  14. <center><h1 class="logintitle">Identifikohuni</h1></center>
  15. <form action="registeradmin.php" method="post">
  16. <div class="inner_container">
  17.  
  18. <input class="login-input" type="text" placeholder="Fusni Username" name="username" required> <br>
  19.  
  20. <input class="login-input" type="password" placeholder="Fusni password-in" name="password" required> <br>
  21.  
  22. <input class="login-input" type="password" placeholder="Konfirmo Password-in" name="cpassword" required><br>
  23.  
  24. <input class="login-input" type="text" name="psig" placeholder="Pyetja e sigurise ">
  25.  
  26. <button name="registeradmin" class="login-button" type="submit">Rregjistrohu</button>
  27. <a href="index.php"><button type="button" class="login-button"><< Kthehu ne fillim</button></a>
  28.  
  29. </div>
  30. </form>
  31.  
  32. <?php
  33. if(isset($_POST['registeradmin']))
  34. {
  35. @$username=$_POST['username'];
  36. @$password=$_POST['password'];
  37. @$cpassword=$_POST['cpassword'];
  38. @$psig=$_POST['psig'];
  39.  
  40. if(($password == $cpassword) && ($psig === '123'))
  41.  
  42. {
  43. $query = "select * from admin where user='$username'";
  44.  
  45. $query_run = mysqli_query($con,$query);
  46. //echo mysql_num_rows($query_run);
  47. $numero = " select count (user) from admin ";
  48. $numero_run = mysqli_query($con, $numero);
  49. if(($query_run) &&($numero_run))
  50. {
  51. if(mysqli_num_rows($query_run)>0)
  52. {
  53. echo '<script type="text/javascript">alert("This Username Already exists.. Please try another username!")</script>';
  54. }
  55.  
  56. elseif (mysqli_num_rows($numero_run)>1) {
  57. echo '<script type="text/javascript">alert("there cant be more than 1 user registred ")</script>';
  58. }
  59.  
  60.  
  61. else
  62. {
  63. $query = "insert into admin values('$username','$password')";
  64. $query_run = mysqli_query($con,$query);
  65. if($query_run)
  66. {
  67. echo '<script type="text/javascript">alert("User Registered.. Welcome")</script>';
  68. $_SESSION['username'] = $username;
  69. $_SESSION['password'] = $password;
  70. header( "Location: homepage.php");
  71.  
  72. }
  73. else
  74. {
  75. echo '<p class="bg-danger msg-block">Registration Unsuccessful due to server error. Please try later</p>';
  76. }
  77. }
  78. }
  79. else
  80. {
  81. echo '<script type="text/javascript">alert("DB error")</script>';
  82. }
  83. }
  84. else
  85. {
  86. echo '<script type="text/javascript">alert("Password-et nuk perputhen ose pyetja e sigurise gabim")</script>';
  87.  
  88.  
  89. }
  90.  
  91. }
  92. ?>
  93. </div>
  94. </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement