我做了一个登陆的页面login.php,想通过action提交到页面checklogin.php来处理数据,可是每当我点击登陆按钮时,它只是将我填写的内容清空,我已经上网查找了很多的方法,还是没有办法,现在我把我的源代码贴出,请各位高手指教
login.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> 会员登录 </title>
<style type="text/css">
<!--
@import url("css/shop.css");
.STYLE3 {
font-size: 14px;
color: #2d58b1;
font-weight: bold;
}
.STYLE6 {font-size: 12px;color: #0033CC;}
.STYLE7 {font-size: 10px}
.STYLE9 {font-size: 13px}
.STYLE10 {color: #2D58B1}
.STYLE11 {
font-size: 13px;
color: #2D58B1;
font-weight: bold;
}
-->
</style>
<script type="text/javascript">
<!--
var whitespace = "
"; // 定义空白字符
function isEmpty(s){ //输入内容搜索
var i;
if((s == null) ¦ ¦ (s.length == 0))
return true;
for (i = 0; i < s.length; i++) { // 在字符串中寻找非空白字符
var c = s.charAt(i);
if (whitespace.indexOf(c) == -1)
return false;
}
// 在这一点上,所有字符都是空白字符.
return true;
}
function validate(){ //验证输入是否为空
if (isEmpty(document.login.username.value))
{
alert("错误!用户名必须输入!"); //如果为空,给出提示
document.login.username.focus(); //获得焦点,要求重新输入
return false;
}
if (isEmpty(document.login.password.value)){ //验证输入是否为空
alert("错误!密码必须输入!"); //如果为空,给出提示
document.login.password.focus(); //获得焦点,要求重新输入
return false; 数据挖掘工具
}
if (isEmpty(document.login.test.value)){ //验证输入是否为空
alert("错误!验证码必须输入!"); //如果为空,给出提示
document.login.test.focus(); //获得焦点,要求重新输入
return false;
}
return true;
}
//-->
</script>
</head>
<body>
<div align="center">
<table width="762" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<?php
include "head.php";
?>
</table>
<form action="checklogin.php" name="login" method="get" onsubmit="return validate()">
<table width="421" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="421" height="41" align="left" valign="middle" background="images/index/lg01.gif"> <span class="STYLE3"> 会员登录 </span> </td>
</tr>
<tr>
<td height="295" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7" height="282" valign="top" background="images/index/lg04.gif"> </td>
<td width="407" valign="top" background="images/index/lg07.gif"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="17" colspan="2"> </td>
</tr>
<tr>
<td height="45" colspan="2" align="center" valign="middle"> <span class="STYLE9"> <strong> <span class="STYLE10"> 用户名: </span> </strong> </span> <span class="STYLE9"> 数据挖掘论坛
<input type="text" class="STYLE9" size="21" name="username" id="username"/>
</span> </td>
</tr>
<tr>
<td height="45" colspan="2" align="center" valign="middle" class="STYLE7"> <span class="STYLE11"> 密 码:
<input name="password" class="STYLE9" id="password" size="22" type="password"/> 数据挖掘论坛
</span> </td>
</tr>
<tr>
<td height="45" colspan="2" align="left" valign="middle" class="STYLE11"> 验证码:
<input class="STYLE9" size="13" name="test" />
<img src="testcode.php" alt="" name="testcode" width="80" height="26" id="testcode" /> </td> 数据挖掘工具
</tr>
<tr>
<td width="209" height="58" align="center" valign="middle"> <img src="images/index/lg09.gif" width="12" height="12" /> <strong class="STYLE11"> <a href="getpwd.php"> 忘记密码 </a> </strong> <img src="images/index/lg09.gif" width="12" height="12" /> <strong class="STYLE11"> <a href="registe.php"> 注册 </a> </strong> </td> 数据挖掘交友
<td width="198" align="left" valign="middle"> <input type="image" src="images/index/lg10.gif" width="75" height="23" name="btlogin"/> </td>
</tr>
<tr>
<td height="72" colspan="2" align="center" valign="middle"> <img src="images/index/lg11.gif" width="154" height="58" /> </td>
</tr> 数据挖掘交友
</table> </td>
<td width="7" valign="top" background="images/index/lg05.gif"> </td>
</tr>
<tr>
<td height="13" colspan="3" valign="top"> <img src="images/index/lg03.gif" width="420" height="13" /> </td>
</tr>
</table> </td>
</tr>
<tr> 数据挖掘研究院
<td height="6"> </td>
</tr>
</table>
</form>
<?php
include "../foot.php";
?>
</div>
</body>
</html>
眼都花了。
你的submit在哪呢,提交那个input用submit呀。
<input type="image"/> 默认就是submit
form一直没有被提交,可能是你的validate()函数一直返回false
可以调试以下你的js代码 <form action="checklogin.php" enctype="multipart/form-data" name="login" target="_blank" onsubmit="return validate()">
把这句换一下 不行就是你的js有问题了首先这句if((s == null) ? ? (s.length == 0))要写成这个样if((s == null) ¦ ¦ (s.length == 0))另外你把method="get" 改为method="post"看看可不可以Create By Any-Extract(WL-AE)
数据挖掘论坛