码迷,mamicode.com
首页 > 数据库 > 详细

MySQL_PHP学习笔记_2015_0906_使用PHP模板

时间:2015-09-06 16:07:29      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

1. 功能说明:

index.php自动作出选择.

如果没有传入参数,则加载 form.html.php; 如果有传入参数(并且有参数firstName), 则加载welcome.html.php显示姓名.

 

本人, 还在学习的初级阶段, 如果你已然入门或是牛人, 请自动略过本文, 写这些纯粹是为了加深学习印象, 不是干货, 见谅…

 

2. 郊果:

初始界面:

技术分享

跳转界面:

技术分享

3. 目录welcome下一共有如下三个文件,默认加载 index.php:

index.php

form.html.php

welcome.html.php

 

4. 代码

index.php

<?php
  if (!isset($_REQUEST[‘firstName‘]))
  {
      include ‘form.html.php‘;
  }
  else
  {
      $firstName = $_REQUEST[‘firstName‘];
      $lastName = $_REQUEST[‘lastName‘];
      
      $output = ‘Welcome to our website, ‘
              .htmlspecialchars($firstName, ENT_QUOTES, ‘UTF-8‘)
              .‘ ‘
              .htmlspecialchars($lastName, ENT_QUOTES, ‘UTF-8‘)
              .‘!‘;
      include ‘welcome.html.php‘;
  }

form.html.php

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Input Name</title>
</head>
<body>
  <form action="" method="post">
    <div>
      <label for="firstName">First Name:
        <input type="text" name="firstName" id="firstName">        
      </label>
    </div>
    <div>
      <label for="lastName">Last Name:
        <input type="text" name="lastName" id="lastName">
      </label>
    </div>
    <div>
      <input type="submit" value="GO">
    </div>
  </form>
</body>
</html>

welcome.html.php

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Form example</title>
</head>
<body>
  <p>
    <?php echo $GLOBALS[‘output‘]; ?>
  </p>
</body>
</html>

MySQL_PHP学习笔记_2015_0906_使用PHP模板

标签:

原文地址:http://www.cnblogs.com/BigBigLiang/p/4785728.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!