Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <head>
- <style>
- <?php include 'benjamin/main.css'; ?>
- </style>
- </head>
- <body>
- <center>
- <img src="images/welcome_pic.jpg" alt="WelcomeMat" style="width: 600px; height: 300px;">
- <br><br>
- <?php
- if (isset($_POST['submit'])) {
- try {
- /* Fullname */
- if (!isset($_POST['fullname']))
- throw new Exception('Missing fullname');
- if (empty($_POST['fullname']))
- throw new Exception('Empty fullname');
- if (!pref_match("/^[a-zA-Z ]*$/")) {
- $nameErr = "Only letters and white space allowed in Full Name";
- }
- $fullname = $_POST['fullname'];
- /* Username */
- if (!isset($_POST['username']))
- throw new Exception('Missing username');
- if (empty($_POST['username']))
- throw new Exception('Empty username');
- if (!preg_match("/^[a-zA-Z ]*$/",$username)) {
- $usernameErr = "Only letters and White space allowed in username";
- }
- $username = $_POST['username'];
- /* Password */
- if (!isset($_POST['password']))
- throw new Exception('Missing password');
- if (empty($_POST['password']))
- throw new Exception('Empty password');
- $password = md5($_POST['password']);
- /* Email */
- if (!isset($_POST['email']))
- throw new Exception('Invalid Email')
- /* DB insert */
- $query = "INSERT INTO `users` (`fullName`, `username`, `password`, `email`)VALUES('" . $fullname . "', '" . $username . "', '" . $password . "', '" . $email . "');";
- $sql = mysqli_query($query);
- if (!$sql)
- throw new Exception('En feil oppstod ved registrering');
- /* Redirect to dashboard */
- echo 'Vellykket! Du er nå registrert';
- /*
- echo '
- <script type="text/javascript">
- window.location.href = "dashboard.php";
- </script>
- ';
- */
- }
- }
- ?>
- <fieldset>
- <legend>Registration</legend>
- <form method="post">
- <input type='hidden' name='submitted' value='1'/>
- <label for='fullname' >Full Name: </label>
- <input type='text' name='fullname' id='fullname' maxlength="50" />
- <label for='email' >Email:</label>
- <input type='text' name='email' id='email' maxlength="50" />
- <label for='username' >Username:</label>
- <input type='text' name='username' id='username' maxlengt="50" />
- <label for='password' >Password:</label>
- <input type='password' name='password' id='password' maxlength="50" />
- <input type='submit' name='submit' value='Submit' />
- </form>
- </fieldset>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement