万卷书   首页 > 电脑书籍 > Dreamweaver > Dreamweaver MX技巧汇粹
 
   在页面上建立基本的表单,名字为login.htm,大家注意:我们在 的action属性中填写的是文件本身,后面还给了他一个url参数,这个参数就是用来控制页面中asp代码的执行的。代码如下:
   < html >
   < head >
   < title >Untitled Document< /title >
   < meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
   < /head >

   < body >
   < form name="form1" method="post" action="login.htm?action=yes" >
   < p >
   < input type="text" name="textfield2" >
   < /p >
   < p >
   < input type="text" name="textfield" >
   < /p >
   < p >
   < input type="submit" name="发送" value="Submit" >
   < /p >
   < /form >
   < /body >
   < /html >

   下面我们来添加if控制语句:
   < html >
   < head >
   < title >Untitled Document< /title >
   < meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
   < /head >

   < body >
   < % if Request.QueryString("action")="" then % >
   < form name="form1" method="post" action="login.htm?action=yes" >
   < p >
   < input type="text" name="textfield2" >
   < /p >
   < p >
   < input type="text" name="textfield" >
   < /p >
   < p >
   < input type="submit" name="发送" value="Submit" >
   < /p >
   < /form >
   < %
   else
   Response.write "欢迎你,都市无情人"
   End if
   % >
   < /body >
   < /html >
   当最初执行login.htm的时候,由于没有url参数,所以Request.QueryString("action")=""是空值,在页面上生成表单,当我们在页面上填写用户名字和密码时,提交表单,< form name="form1" method="post" action="login.htm?action=yes" >这时候,Request.QueryString("action")="yes",不是空,所以在页面上执行Response.write "欢迎你,都市无情人"

   看到没,我们就加了几行asp代码就把两个页面并到了一起,简单吧。当然这是个登录系统,还要校验用户输入的密码是否正确,这里就不在阐述了,因为用dwmx很容易作到,我们只讨论技巧,如果你要做个登录系统,先花两分钟时间用mx搞定,然后再在里面插入上面if语句就可以了。哈哈…



上一页