用html和后端php写一个简单表单

表单.html

<!DOCTYPE html>

<html >

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>form表单</title>

</head>

<body>

<form action="表单.php" method="post">

    姓名:<input type="text" name="name"><br>

    性别:

    <input type="radio" name="男">男

    <input type="radio" name="女">女<br>

    电话:<input type="text" name="phone number"><br>

    学历:

    <select name="education[]">

        <option value="小学">小学</option>

        <option value="初中">初中</option>

        <option value="高中">高中</option>

        <option value="本科">本科</option>

        <option value="研究生">研究生</option>

        <option value="博士">博士</option>

        <option value="社会">社会</option>

    </select><br>

    家庭住址:<input type="text" name="address"><br>

    兴趣爱好:<input type="text" name="hobby"><br>

    个人特长:<input type="text" name="specialty"><br>

    <input type="submit" value="提交">

</form>    

</body>

</html>

表单.php

<?php

$method=$_SERVER["REQUEST_METHOD"];





 

if($method=="POST"){

  $name=$_POST["name"];

  $sex=$_POST["sex"];

  $phone number=$_POST["phone number"];

  $education=$_POST["education"];

  $address=$_POST["address"];

  $hobby=$_POST["hobby"];

  $specialty=$_POST["specialty"];



 

  echo '姓名:'.$name;

  echo '性别:'.$sex;

  echo '学历:'.$education;

  echo '家庭住址:'.$address;

  echo '兴趣爱好:'.$hobby;

  echo '个人特长:'.$specialty;

}

else if($method=="GET"){



 

}