Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL && ~E_NOTICE);
- session_start();
- if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['cpassword'])){
- //capcha
- if($_POST['result']){
- $r = $_POST['result'];
- if($r == $acctualr){
- $pass = strip_tags($_POST['password']);
- $cpass = strip_tags($_POST['cpassword']);
- $user = $_POST['username'];
- //check if the passwords match
- if( $pass == $cpass ){
- include_once("connection.php");
- //insert user into database
- $sql = "INSERT INTO korisnici"."(username,password)"."VALUES('$user', '$pass')";
- $query = mysqli_query($db, $sql);
- if($query){
- //prenesi na korisnichka verzija na str
- $_SESSION['username'] = $user;
- header('Location: user.php');
- }
- else{
- echo "There was a problem creating your account.";
- }
- }
- else{
- echo "Passwords don't match.";
- }
- }
- else{
- echo "You didn't enter the right result.";
- }
- }
- else{
- echo "You didn't enter a result!";
- }
- }
- ?>
- <!DOCTYPE html >
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="style.css"/>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Register</title>
- </head>
- <body>
- <h1> Register </h1>
- <form method="post">
- <div> Username: <input type="text" name="username" placeholder="Create a username.." /></div>
- <div> Password: <input type="password" name="password" placeholder="Create a password.." /></div>
- <div> Confirm : <input type="password" name="cpassword" placeholder="Confirm password.." /></div>
- <?php
- $min = 1;
- $max = 20;
- $randomNumber1 = mt_rand($min, $max);
- $randomNumber2 = mt_rand($min, $max);
- echo $randomNumber1." + ".$randomNumber2." = ";
- $acctualr =$randomNumber1+$randomNumber2;
- ?>
- <input type="text" name="result" placeholder="Calculate.."/>
- <div> <input type="submit" name="register" value="Register!" /> </div>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment