Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //start session
- if (!isset($_SESSION)){
- session_start();
- }
- include_once "functions.php";
- //call function to check if the username is free - if no - ask for new username
- $error_message = "";
- if (isset($_POST, $_POST["username"])) {
- if (isUsernameFree($_POST["username"])){
- //call function to create user and set this data in session
- $user = createUser($_POST, $_FILES);
- if (is_array($user)){
- $_SESSION["user"] = $user;
- header("Location: dashboard.php");
- }
- else {
- $error_message = $user;
- }
- }
- else {
- $error_message = "This username is not free.";
- }
- } else {
- }
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>register</title>
- <link rel="stylesheet" href="register.css">
- </head>
- <body>
- <header>Welcome to MySvalka</header>
- <!--
- form with require fields for:
- username
- password
- e-mail
- age - must be positive number
- gender - male or female
- looking for - male, female or both of them
- something about - less than 100 characters
- profile picture
- register button - if press it - go to dashboard page
- -->
- <div id="forms">
- <div><?php echo $error_message;?></div>
- <form action="register.php" method="post" enctype="multipart/form-data">
- <label for="username">Username: </label>
- <input type="text" name="username" required value="<?php if (isset($_POST, $_POST["username"])) echo htmlentities($_POST['username']);?>"> <br><br>
- <label for="password">Password: </label>
- <input type="password" name="password" required value="<?php if (isset($_POST, $_POST["password"])) echo htmlentities($_POST['password']);?>"> <br><br>
- <label for="email">E-mail: </label>
- <input type="email" name="email" required value="<?php if (isset($_POST, $_POST["email"])) echo htmlentities($_POST['email']);?>"> <br><br>
- <label for="age">Age: </label>
- <input type="number" name="age" min="0" max="105" required value="<?php if (isset($_POST, $_POST["age"])) echo htmlentities($_POST['age']);?>"> <br><br>
- <label for="gender">Gender: </label>
- <select name="gender">
- <option value="">Select</option>
- <option value="male" <?php if (isset($_POST, $_POST["gender"]) && $_POST["gender"] == "male") echo "selected";?>>Male</option>
- <option value="female" <?php if (isset($_POST, $_POST["gender"]) && $_POST["gender"] == "female") echo "selected";?>>Female</option>
- </select>
- <br><br>
- <label for="lookingfor">Looking for: </label>
- <select name="lookingfor">
- <option value="">Select</option>
- <option value="male" <?php if (isset($_POST, $_POST["lookingfor"]) && $_POST["lookingfor"] == "male") echo "selected";?>>Male</option>
- <option value="female" <?php if (isset($_POST, $_POST["lookingfor"]) && $_POST["lookingfor"] == "female") echo "selected";?>>Female</option>
- <option value="both" <?php if (isset($_POST, $_POST["lookingfor"]) && $_POST["lookingfor"] == "both") echo "selected";?>>Both</option>
- </select>
- <br><br>
- <label for="info">Tell something about you: </label>
- <input type="text" name="info" maxlength="100" required value="<?php if (isset($_POST, $_POST["info"])) echo htmlentities($_POST['info']);?>"> <br><br>
- <label for="image">Upload image: </label>
- <input type="file" name="image"> <br><br>
- <input type="submit" name="register" value="Register ">
- </form>
- </div>
- <footer>Enjoy</footer>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement