Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>>
- <?php
- include '../includes/head.php';
- $username = $_POST['username'];
- $publicname = $_POST['publicname'];
- $password = $_POST['password'];
- ?>
- </head>
- <body>
- <?php
- if(isset($_POST['submit'])){
- if(strlen($_POST['username']) < 3){
- $error[] = 'Uživatelské jméno je příliš krátké (minimální počet znaků je 3).';
- } else {
- $stmt = $db->prepare('SELECT username FROM user WHERE username = $username');
- $stmt->execute(array(':username' => $_POST['username']));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- if(!empty($row['username'])){
- $error[] = 'Uživatelské jméno je již používáno.';
- }
- }
- if(strlen($_POST['password']) < 3){
- $error[] = 'Heslo je příliš krátké (minimální počet znaků je 3).';
- }
- if(!isset($error)){
- //hash the password
- $hashedpassword = md5($password);
- $sql = "INSERT INTO user (username, publicname, password) VALUES ('$username','$publicname','$hashedpassword')";
- }
- //check for any errors
- if(isset($error)){
- foreach($error as $error){
- echo '<p class="bg-danger">'.$error.'</p>';
- }
- }
- echo '<a href=\"../index.php\">Zpět</a>';
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement