Advertisement
Guest User

Untitled

a guest
Oct 11th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3.  
  4. <style>
  5. <?php include 'benjamin/main.css'; ?>
  6. </style>
  7.  
  8. </head>
  9. <body>
  10. <center>
  11. <img src="images/welcome_pic.jpg" alt="WelcomeMat" style="width: 600px; height: 300px;">
  12. <br><br>
  13. <?php
  14.  
  15.  
  16. if (isset($_POST['submit'])) {
  17.  
  18. try {
  19.  
  20. /* Fullname */
  21. if (!isset($_POST['fullname']))
  22. throw new Exception('Missing fullname');
  23.  
  24. if (empty($_POST['fullname']))
  25. throw new Exception('Empty fullname');
  26.  
  27. if (!pref_match("/^[a-zA-Z ]*$/")) {
  28. $nameErr = "Only letters and white space allowed in Full Name";
  29. }
  30.  
  31. $fullname = $_POST['fullname'];
  32.  
  33. /* Username */
  34. if (!isset($_POST['username']))
  35. throw new Exception('Missing username');
  36.  
  37. if (empty($_POST['username']))
  38. throw new Exception('Empty username');
  39.  
  40. if (!preg_match("/^[a-zA-Z ]*$/",$username)) {
  41. $usernameErr = "Only letters and White space allowed in username";
  42. }
  43.  
  44. $username = $_POST['username'];
  45.  
  46. /* Password */
  47. if (!isset($_POST['password']))
  48. throw new Exception('Missing password');
  49.  
  50. if (empty($_POST['password']))
  51. throw new Exception('Empty password');
  52.  
  53. $password = md5($_POST['password']);
  54.  
  55. /* Email */
  56. if (!isset($_POST['email']))
  57. throw new Exception('Invalid Email')
  58.  
  59. /* DB insert */
  60. $query = "INSERT INTO `users` (`fullName`, `username`, `password`, `email`)VALUES('" . $fullname . "', '" . $username . "', '" . $password . "', '" . $email . "');";
  61. $sql = mysqli_query($query);
  62.  
  63. if (!$sql)
  64. throw new Exception('En feil oppstod ved registrering');
  65.  
  66. /* Redirect to dashboard */
  67. echo 'Vellykket! Du er nå registrert';
  68. /*
  69. echo '
  70. <script type="text/javascript">
  71. window.location.href = "dashboard.php";
  72. </script>
  73. ';
  74. */
  75. }
  76. }
  77.  
  78. ?>
  79.  
  80. <fieldset>
  81. <legend>Registration</legend>
  82. <form method="post">
  83. <input type='hidden' name='submitted' value='1'/>
  84. <label for='fullname' >Full Name: </label>
  85. <input type='text' name='fullname' id='fullname' maxlength="50" />
  86.  
  87. <label for='email' >Email:</label>
  88. <input type='text' name='email' id='email' maxlength="50" />
  89.  
  90. <label for='username' >Username:</label>
  91. <input type='text' name='username' id='username' maxlengt="50" />
  92.  
  93. <label for='password' >Password:</label>
  94. <input type='password' name='password' id='password' maxlength="50" />
  95.  
  96. <input type='submit' name='submit' value='Submit' />
  97. </form>
  98. </fieldset>
  99.  
  100. </center>
  101. </body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement