25 lines
		
	
	
		
			695 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			695 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
session_start();
 | 
						|
require_once 'config.php';
 | 
						|
 | 
						|
// Handle registration form submission
 | 
						|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
 | 
						|
    $username = $_POST['username'];
 | 
						|
    $email = $_POST['email'];
 | 
						|
    $password = $_POST['password'];
 | 
						|
 | 
						|
    // Hash the password
 | 
						|
    $hashed_password = password_hash($password, PASSWORD_DEFAULT);
 | 
						|
 | 
						|
    // Insert user into the database
 | 
						|
    $query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$hashed_password')";
 | 
						|
    $result = mysqli_query($mysqli, $query);
 | 
						|
 | 
						|
    if ($result) {
 | 
						|
        echo "Registration successful. <a href='login.html'>Login here</a>.";
 | 
						|
    } else {
 | 
						|
        echo "Error: " . mysqli_error($mysqli);
 | 
						|
    }
 | 
						|
}
 | 
						|
?>
 |