php 学习 (4)

来源:互联网 发布:信息技术编程 编辑:程序博客网 时间:2024/06/05 20:14

下面给出两个示例:

示例一:输入年月日;获得年月日;并跳转页面;

<meta http-equiv="Content-Type" content="text/html; charset=GB2312"><title>无标题文件</title></head><body><table width="100%"  border="0" align="left">  <tr>    <td><form name="form1" method="post" action="showtextdata.php">         <!-- 将数据发送到showtextdata.php网页-->请输入您的出生年月日:<br>         <input name="year" type="text" id="year" size="5" maxlength="4"> <!--年 --> /         <input name="month" type="text" id="month" size="3" maxlength="2"> <!-- 月--> /         <input name="day" type="text" id="day" size="3" maxlength="2"> <!—日 -->         <input type="submit" name="Submit" value="发送 ">        </form></td>  </tr></table></body></html>



<?echo "您所输入的出生年月日为:<br>";echo $year;echo "/";echo $month;echo "/";echo $day;?>

输入密码 并显示密码 跳转页面

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=GB2312"><title>无标题文件</title></head><body><form name="form1" method="get" action="getpasw.php">会员账号<input name="access" type="text" size="13" maxlength="12"><br>会员密码<input name="pasw" type="password" size="13" maxlength="12"><br><input type="submit" name="Submit" value="发送"></form></body></html>

<?echo "您所输入的账号为:<br>";echo $access;echo "<br>";echo "您所输入的密码为:<br>";echo $pasw;?>
两个小程序,都是通过html的form标签来跳转的,method给出了传值方式,action给出了传值的对象