想使用html +php +mysql 製作一個登入加上註冊的網站,但是一直無法成功註冊

想使用html +php +mysql 製作一個登入加上註冊的網站,但是一直無法成功註冊程式碼如下(register.php)

<?php 
$conn=require_once("test.php");

if($_SERVER["REQUEST_METHOD"]=="POST"){
    $username=$_POST["username"];
    $password=$_POST["password"];

    $check="SELECT * FROM leo WHERE username='".$username."'";
    if(mysqli_num_rows(mysqli_query($conn,$check))==0){
        $sql="INSERT INTO leo (id,username, password)
            VALUES(NULL,'".$username."','".$password."')";
        
        if(mysqli_query($conn, $sql)){
            echo "註冊成功";
            
            header("refresh:32;url=index.php");
            exit;
        }else{
            echo "失敗 " . mysqli_error($conn);
        }
    }
    else{
        echo "已經有人註冊了";
        echo "<a href='register.html'>未成功跳轉頁面請點擊此</a>";
        header('HTTP/1.0 302 Found');
        //header("refresh:3;url=register.html",true);
        exit;
    }
}


mysqli_close($conn);

function function_alert($message) { 
      
    // Display the alert box  
    echo "<script>alert('$message');
     window.location.href='index.php';
    </script>"; 
    
    return false;
} 
?>

register.html

<!DOCTYPE html><html><head>
    <meta charset="UTF-8">
    <title>註冊新帳號</title></head><body>
    <p>
        <b>註冊新帳號</b>
        <form action="register.php" method="post">
            <p><span>用戶名:</span><input type="text" name="username" id="username" required=""/></p>
            <p><span>密碼:</span><input type="password" name="password" id="password" required=""/></p>
         
            <p>
                <input type="reset" name=""/> <input type="submit" name=""/>
            </p>
        </form>
      

    </body>
    </html>

test.php


```php

<?php
    $db_link=@mysqli_connect("localhost","id18894996_hungleo","Leoleo67336431.");
    if(!$db_link){
        die("資料庫連線失敗<br>");
    }else{
        echo"資料庫連線成功<br>";
    }
    mysqli_query($db_link,"SET NAMES 'utf-8'");  
    $seldb=@mysqli_select_db($db_link,"id18894996_leo");
    if(!$seldb){
        die("資料庫選擇失敗<br>");
    }else{
        echo"資料庫選擇成功<br>";
    }
?>

失敗畫面如下

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/992217838256181.jpg "#left")


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/257327838256187.jpg "#left")
mqsql 截圖

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/305587838256117.jpg "#left")

你的数据表看截图没有id字段啊

不确定什么原因最好提供一下源码