Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($stmt->execute()):
- echo 'Well done! You have successfully registered with us!';
- else:
- echo 'There seems to be an issue getting you registered.';
- <?php
- ini_set('display_errors', 'On');
- ini_set('html_errors', 0);
- error_reporting(-1);
- require 'connection.php';
- $message = '';
- if (!empty($_POST['username']) && !empty($_POST['password'])):
- // $username = $_POST['username'];
- $password = $_POST['password'];
- $confirmpassword = $_POST['confirmpassword'];
- //var_dump($password, $confirmpassword);
- if($password == $confirmpassword):
- $sql = "INSERT INTO users (FirstName, LastName, Role, Email, Username, Password) VALUES (:firstname, :lastname, :role, :email, :username, :password)";
- $stmt = $conn->prepare($sql);
- $hashPassword = password_hash($password, PASSWORD_DEFAULT);
- $stmt->bindParam(':firstname', $_POST['firstname']);
- $stmt->bindParam(':lastname', $_POST['lastname']);
- $stmt->bindParam(':role', $_POST['role']);
- $stmt->bindParam(':email', $_POST['email']);
- $stmt->bindParam(':username', $_POST['username']);
- $stmt->bindParam(':password', $hashPassword);
- if ($stmt->execute()):
- echo 'Well done! You have successfully registered with us!';
- //$message = 'Well done! You have successfully registered with us!';
- //header('Location:loginPage.php');
- else:
- echo 'There seems to be an issue getting you registered.';
- //$message = 'There seems to be an issue getting you registered.';
- //else:
- //echo 'Your passwords do not match!';
- //$message = 'Your passwords do not match, please enter them correctly.';
- endif;
- endif;
- endif;
- --><form class="col-1-3" action="register.php" method="post">
- <fieldset class="register-group">
- <label>
- <br>First Name*
- <input type="text" name="firstname" placeholder="FirstName" value="<?php echo $firstname; ?>">
- </label>
- <label>
- Last Name*
- <input type="text" name="lastname" placeholder="LastName" value="<?php echo $lastname; ?>">
- </label>
- <label>
- Role*
- <select name="role">
- <option value="Student" selected>Student</option>
- <option value="Tutor" selected>Tutor</option>
- <option value="Admin" selected>Admin</option>
- </select>
- </label>
- <label>
- Email Address*
- <input type="email" name="email" placeholder="Email" value="<?php echo $email; ?>">
- </label>
- <label>
- Choose a Username*
- <input type="text" name="username" placeholder="Username" value="<?php echo $username; ?>">
- </label>
- <label>
- Choose a Password*
- <input type="password" name="password" placeholder="Password">
- </label>
- <label>
- Repeat Password*
- <input type="password" name="confirmpassword" placeholder="Confirm Password">
- </label>
- <input class="btn btn-default" type="submit" name="register" value="Register">
- </form>
- if (!empty($_POST['username']) && !empty($_POST['password'])):
- //...
- if($password == $confirmpassword):
- //...
- if ($stmt->execute()):
- echo 'Well done! You have successfully registered with us!';
- //...
- else:
- echo 'There seems to be an issue getting you registered.';
- //...
- endif;
- else:
- echo 'Your passwords do not match!';
- //...
- endif;
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement