<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><link rel="stylesheet"href="p.css"/><script src="c.js" type="text/jscript"></script>
<title>Check</title></head>
<body>
<form id="f" method="get" onsubmit="return d()"><div id="s" class="c">
<div><input id="B" class="b3" type="button" value="Check"></input></div>
<span class="b4">Check Code</span>
<div><input type="text" class="t1" maxlength="20" name="T"/></div></div>
</form>
<div id="v" class="o c">6~20 characters</div>
</body></html>

在这个log.php页面里,如果用户输入的校验码,字符数在6到20之间。点击按钮后,则跳转到data.php页面。否则,点击按钮后,就跳转到failure.htm页面。请问,用PHP如何实现?请把PHP代码填充到上面的XHTML代码里。

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><link rel="stylesheet"href="p.css"/><script src="c.js" type="text/jscript"></script>
    <title>Check</title></head>
    <body>
    <form id="f" method="post" action="submit.php"><div id="s" class="c">
    <div><input id="B" class="b3" type="submit" value="Check"></input></div>
    <span class="b4">Check Code</span>
    <div><input type="text" class="t1" maxlength="20" name="T"/></div></div>
    </form>
    <div id="v" class="o c">6~20 characters</div>
    </body></html>
    submit.php<?php 
    $t=$_POST['T'];

    if(strlen($t)<=20 && strlen($t)>=6){

    header("Location:data.php");

    }else{
    header("Location:failure.htm");
    }?>
      

  2.   

    楼上是对的,帮忙补充下吧,让那个表格提交后转到楼上写的那个submit.php的页面,然后通过这个submit.php的页面来分析用户输入的密码的长度,然后再跳转到不同页面.
      

  3.   

    呵呵,用ASP.NET多了。所以误以为PHP和XHTML必须是在同一个页面里实现。