您的位置:首页 >> Web开发 >> CGI技术 >> 正文
RSS
 

一个例子

http://www.rdxx.com 06年04月21日 07:27 网海之贝 我要投稿

关键词:
#!/usr/bin/perl -w
让用户输入用户名和密码

use strict;
use CGI;

#检查用户名和密码开始
my $mycgi=new CGI;

print <<HEADPART;
content-type:text/html

<html><head><title>test it :)</title>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<SCRIPT language="javascript">
<!--
var never = new Date()
never.setTime(never.getTime() + 2000*24*60*60*1000);

function SetCookie(name, value)
{
    var expString = "; expires=" + never.toGMTString();
    documents.cookie = name + "=" + escape(value) + expString;
}

// returns value of cookie or null if cookie does not exist
function GetCookie(name)
{
    var result = null;
    var myCookie = " " + documents.cookie + ";";
    var searchName = " " + name + "=";
    var startOfCookie = myCookie.indexOf(searchName);
    var endOfCookie;
    if (startOfCookie != -1)
    {
        startOfCookie += searchName.length; // skip past name of cookie
        endOfCookie = myCookie.indexOf(";", startOfCookie);
        result = unescape(myCookie.substring(startOfCookie, endOfCookie));
    }
    return result;
}
function gogo()
{
    SetCookie('username',document.form1.username.value);
    SetCookie('password',document.form1.password.value);
    document.form1.submit();
}
// -->
</SCRIPT>
</head>

<body bgcolor="#FFFFFF">

<form name=form1 method=post action='/***/other.pl' enctype='multipart/form-data'>
  <p>用户名:
    
<script language=javascript>
<!--
    var username=GetCookie("username");
    if (username==null)
    {
        document.write ('<input type=text name=username class=p1>');
共2页  第1页 第2页

 
 
标签: 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站