Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <?php
  2. //start session
  3. if (!isset($_SESSION)){
  4. session_start();
  5. }
  6. include_once "functions.php";
  7. //call function to check if the username is free - if no - ask for new username
  8. $error_message = "";
  9.  
  10. if (isset($_POST, $_POST["username"])) {
  11.  
  12. if (isUsernameFree($_POST["username"])){
  13.  
  14. //call function to create user and set this data in session
  15. $user = createUser($_POST, $_FILES);
  16. if (is_array($user)){
  17. $_SESSION["user"] = $user;
  18. header("Location: dashboard.php");
  19. }
  20. else {
  21. $error_message = $user;
  22. }
  23.  
  24. }
  25. else {
  26. $error_message = "This username is not free.";
  27. }
  28. } else {
  29.  
  30. }
  31.  
  32. ?>
  33.  
  34. <!doctype html>
  35. <html lang="en">
  36. <head>
  37. <meta charset="UTF-8">
  38. <meta name="viewport"
  39. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  40. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  41. <title>register</title>
  42. <link rel="stylesheet" href="register.css">
  43. </head>
  44. <body>
  45. <header>Welcome to MySvalka</header>
  46. <!--
  47. form with require fields for:
  48. username
  49. password
  50. e-mail
  51. age - must be positive number
  52. gender - male or female
  53. looking for - male, female or both of them
  54. something about - less than 100 characters
  55. profile picture
  56.  
  57. register button - if press it - go to dashboard page
  58. -->
  59. <div id="forms">
  60. <div><?php echo $error_message;?></div>
  61. <form action="register.php" method="post" enctype="multipart/form-data">
  62.  
  63. <label for="username">Username: </label>
  64. <input type="text" name="username" required value="<?php if (isset($_POST, $_POST["username"])) echo htmlentities($_POST['username']);?>"> <br><br>
  65.  
  66. <label for="password">Password:&nbsp;</label>
  67. <input type="password" name="password" required value="<?php if (isset($_POST, $_POST["password"])) echo htmlentities($_POST['password']);?>"> <br><br>
  68.  
  69. <label for="email">E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  70. <input type="email" name="email" required value="<?php if (isset($_POST, $_POST["email"])) echo htmlentities($_POST['email']);?>"> <br><br>
  71.  
  72. <label for="age">Age:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  73. <input type="number" name="age" min="0" max="105" required value="<?php if (isset($_POST, $_POST["age"])) echo htmlentities($_POST['age']);?>"> <br><br>
  74.  
  75.  
  76. <label for="gender">Gender:&nbsp;&nbsp;&nbsp;&nbsp;</label>
  77. <select name="gender">
  78. <option value="">Select</option>
  79. <option value="male" <?php if (isset($_POST, $_POST["gender"]) && $_POST["gender"] == "male") echo "selected";?>>Male</option>
  80. <option value="female" <?php if (isset($_POST, $_POST["gender"]) && $_POST["gender"] == "female") echo "selected";?>>Female</option>
  81. </select>
  82. <br><br>
  83.  
  84.  
  85. <label for="lookingfor">Looking for: </label>
  86. <select name="lookingfor">
  87. <option value="">Select</option>
  88. <option value="male" <?php if (isset($_POST, $_POST["lookingfor"]) && $_POST["lookingfor"] == "male") echo "selected";?>>Male</option>
  89. <option value="female" <?php if (isset($_POST, $_POST["lookingfor"]) && $_POST["lookingfor"] == "female") echo "selected";?>>Female</option>
  90. <option value="both" <?php if (isset($_POST, $_POST["lookingfor"]) && $_POST["lookingfor"] == "both") echo "selected";?>>Both</option>
  91. </select>
  92. <br><br>
  93.  
  94.  
  95. <label for="info">Tell something about you: </label>
  96. <input type="text" name="info" maxlength="100" required value="<?php if (isset($_POST, $_POST["info"])) echo htmlentities($_POST['info']);?>"> <br><br>
  97.  
  98. <label for="image">Upload image: </label>
  99. <input type="file" name="image"> <br><br>
  100.  
  101. <input type="submit" name="register" value="Register ">
  102. </form>
  103. </div>
  104.  
  105. <footer>Enjoy</footer>
  106. </body>
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement