实训2 创建一个PHP网页
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style typle="text/css"> table{ width:400px; margin:0 auto; background:#6CF; } div{text-align:center;} </style> <title>hello world</title> </head> <body> <form action="" method="post" width="200%" > <div>个人信息填写表</div> <table border="1" cellpadding="0"> <tr> <th width="78" >姓名</th> <th width="310"><input name="xm" type="text"/></th> </tr> <tr> <th>年龄</th> <th><input name="nl" type="text"/></th> </tr> <tr> <th>爱好</th> <th><input name="ah" type="text"/></th> </tr> </table> <div><input name="send" type="submit" align="center" value="确认" /></div> </form> <?php if(isset($_POST['send'])) { $xm=$_POST['xm']; $nl=$_POST['nl']; $ah=$_POST['ah']; echo '姓名:'.$xm."<br>"; echo '年龄:'.$nl."<br>"; echo '爱好:'.$ah."<br>"; } ?> </body> </html>
在浏览器上预览:可以看到以下界面(文件名称我没有改)
下面输入信息:下面就可以显示了
标签:PHP,第一章,爱好,echo,实训,源代码 From: https://www.cnblogs.com/0625wangqian/p/18220099