<?php
    session_start();
    require("../includes/database_connect.php");

    $username = $_POST['username'];
    $password = $_POST['password'];
    $confirm_password = $_POST['confirm_password'];



    if($password != $confirm_password){
        $_SESSION['error'] = 'Password or Confirm password not same';
        header('location: /stockmanagement/admin/register.php');
    }else{
        $sql = "INSERT INTO users (username,password) values ('$username','$password')";
        $result = mysqli_query($conn, $sql);

        if (!$result) {
            $response = "Something went wrong!";
            $_SESSION['error'] = $response;
              header('location: ../register.php');
        }else{
            $response = "Register Success, Now please login!";
            $_SESSION['success'] = $response;
              header('location: ../login.php');
        }
    
      
    }
   

    
?>