html部分的代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="first.php" method="post">
<input type="text" name="username"/>
<!-- <input type="text" name="age"/> -->
<!-- <input type="text" name="skill"/> -->
<input type="submit" value="提交">
</form>
</body>
</html>
php部分的代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模拟用户数据</title>
</head>
<body>
<?php
$array = array(
'jack' => array('name' => 'jack','age' => 20,'skill' => '帅'),
'rose' => array('name' => 'rose','age' => 18,'skill' => '美'),
'miss' => array('name' => 'miss','age' => 30,'skill' => '坏'),
);
$key = $_POST['username'];
print_r($array[$key]);
$pepole = $array[$key];
echo '<h1>'.$pepole['name'].'欢迎你</h1>';
echo '<h1>我今年'.$pepole['age'].'岁了</h1>';
echo '<h1>我的外表是非常的'.$pepole['skill'].'的</h1>';
?>
</body>
</html>