今天学习了php语言,创建了个人信息的提交信息显示结果的页面

实现php和html的链接

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户信息</title>
</head>
<body>
<form action="php-6.php" method="post">
    姓名:<input type="text" name="name"><br>
    密码:<input type="password" name="password"><br>
    性别:<input type="radio" name="sex" value="男">男<input type="radio" name="sex" value="女">女<br>
    学历:<select name="xueli" id="">
        <option value="硕士">硕士</option>
        <option value="博士">博士</option>
        <option value="本科生">本科生</option>
        <option value="博士后">博士后</option>
    </select><br>
    爱好:<input type="checkbox" name="aihao[]" value="篮球">篮球<input type="checkbox" name="aihao[]" value="象棋">象棋<input type="checkbox" name="aihao[]" value="乒乓球">乒乓球<br>
    <input type="submit" value="提交" style="margin-top:20px">
</form>
</body>
</html>

<?php
    var_dump($_POST);
    $name = $_POST['name'];
    $password = $_POST['password'];
    $sex = $_POST['sex'];
    $xueli = $_POST['xueli'];
    $aihao[] = $_POST['checkbox'];

    echo '姓名:'.$name."<br>";
    echo '密码:'.$password."<br>";
    echo '性别:'.$sex."<br>";
    echo '学历:'.$xueli."<br>";

    $aihao='';
    if(isset($_POST['aihao']))//检测是否存在
    {
        $v = $_POST['aihao'];
        foreach($v as $value)
        {
            $aihao .= $value."/";
        }
    }
    $aihao = substr($aihao,0,-1);
    echo '爱好:'.$aihao;
    ?>

运行结果: