Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- session_start();
- $_SESSION['message'] = '';
- $servername = "localhost";
- $usename = "root";
- $password = "P@ssw0rd";
- $mysqli = new mysqli($servername, $usename, $password, 'accounts');
- if($mysqli->connect_error){
- die("connection Failed: " . $mysqli->connect_error);
- }
- if($_SERVER['REQUEST_METHOD'] == 'POST') {
- if($_POST['password'] == $_POST['password_confirmation']){
- $username = $mysqli->real_escape_string($_POST['username']);
- $email = $mysqli->real_escape_string($_POST['email']);
- $address = $mysqli->real_escape_string($_POST['address']);
- $password = md5($_POST['password']); //md5 beveiliging
- $_SESSION['user_name'] = $username;
- $sql = " INSERT INTO users (username, email, address, password) "
- . "VALUES ('$username', '$email', '$address', '$password')";
- // Als registeren lukt back to welcome.php
- if($mysqli->query($sql) == true) {
- $_SESSION['message'] = 'Registration successful! Welcome $username';
- header("location:index.php");
- }
- else{
- $_SESSION['message'] = "Helaas de poging is mislukt.";
- }
- }else{
- $_SESSION['message'] = "Passwords do not match!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement