Guest User

register.php

a guest
Jul 2nd, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL && ~E_NOTICE);
  3. session_start();
  4.  
  5. if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['cpassword'])){
  6.  
  7. //capcha
  8. if($_POST['result']){
  9.  
  10. $r = $_POST['result'];
  11.  
  12. if($r == $acctualr){
  13.  
  14. $pass = strip_tags($_POST['password']);
  15. $cpass = strip_tags($_POST['cpassword']);
  16. $user = $_POST['username'];
  17.  
  18. //check if the passwords match
  19. if( $pass == $cpass ){
  20. include_once("connection.php");
  21.  
  22. //insert user into database
  23. $sql = "INSERT INTO korisnici"."(username,password)"."VALUES('$user', '$pass')";
  24.  
  25. $query = mysqli_query($db, $sql);
  26. if($query){
  27. //prenesi na korisnichka verzija na str
  28. $_SESSION['username'] = $user;
  29. header('Location: user.php');
  30.  
  31. }
  32.  
  33.  
  34. else{
  35. echo "There was a problem creating your account.";
  36. }
  37.  
  38.  
  39. }
  40. else{
  41. echo "Passwords don't match.";
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. }
  49. else{
  50. echo "You didn't enter the right result.";
  51. }
  52. }
  53. else{
  54. echo "You didn't enter a result!";
  55. }
  56.  
  57.  
  58. }
  59.  
  60. ?>
  61.  
  62. <!DOCTYPE html >
  63. <html>
  64. <head>
  65. <link rel="stylesheet" type="text/css" href="style.css"/>
  66. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  67. <title>Register</title>
  68. </head>
  69.  
  70. <body>
  71. <h1> Register </h1>
  72. <form method="post">
  73. <div> Username: <input type="text" name="username" placeholder="Create a username.." /></div>
  74. <div> Password: <input type="password" name="password" placeholder="Create a password.." /></div>
  75. <div> Confirm : <input type="password" name="cpassword" placeholder="Confirm password.." /></div>
  76.  
  77. <?php
  78. $min = 1;
  79. $max = 20;
  80. $randomNumber1 = mt_rand($min, $max);
  81. $randomNumber2 = mt_rand($min, $max);
  82.  
  83. echo $randomNumber1." + ".$randomNumber2." = ";
  84. $acctualr =$randomNumber1+$randomNumber2;
  85.  
  86. ?>
  87.  
  88.  
  89. <input type="text" name="result" placeholder="Calculate.."/>
  90. <div> <input type="submit" name="register" value="Register!" /> </div>
  91. </form>
  92. </body>
  93. </html>
Add Comment
Please, Sign In to add comment