登录脚本无法按要求运行 [英] Login script not working as required
问题描述
我是php的新手,试图开发一个登录脚本,但是当我输入值时,它不起作用.我什至找不到错误,因为当我单击提交"时,它只会刷新页面
I am new to php and tried to develop a login script but when i enter values it is not working. I cant even find the errors because when i click on submit it just refreshes the page
这是我的代码
<?php include "../utilities/config.php";
foreach($_GET as $key=>$value)
{
${$key} = trim($value);
}
$error = '';
if($checking_member_availability == 'yes'){
if(empty($user_name)){
$error .= "Please enter user name.<br />";
}
if(empty($password)){
$error .= "Please enter password.<br />";
}
if(empty($error)){
$sql = "select * from `".SITE_TABLE_PREFIX."user` where email='".$user_name."' and pwd='".$password."'";
$resultUser = mysql_query($sql) or die(mysql_error().$sql);
if(mysql_num_rows($resultUser)>0){
$rowUser = mysql_fetch_array($resultUser);
$error .= '';
$_SESSION['email']=$user_name;
}else{
$error .= "Please check Email and Password.";
}
}
if(empty($error)){
echo "myaccount.php";
}
else{
echo "<font color='#A01D49'>$error</font>";
}
}
?>
请谁能帮助我,我花了很多时间却没有成功
Please can anyone help me I have spent a lot of time without success
这是html代码
<script type="text/javascript" language="javascript">
function validation()
{
var password = trim(document.form1.password.value);
var user_name = trim(document.form1.user_name.value);
var type = trim(document.form1.type.value);
http.open("GET", "processor.php?checking_member_availability=yes&password="+
escape(password)+"&user_name="+ escape(user_name)+"&type=" + escape(type) , true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
return false;
}
</script>
</head>
<table width="241" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" <?php if($_SESSION['user_id']!=''){?> style="display:none;"<?php }?>>
<tr>
<td align="left" valign="top" class="loginBg">
<img src="img/logintxt.jpg" alt = '' width='100' height='29' border='0'>
</td>
</tr>
<tr>
<td align="left" valign="top" class="login"><form name="form1" id="form1" action="" method="post" onSubmit="return validation();">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="3"><span id="user"></span></td></tr>
<tr>
<td align="left" valign="middle" class="height"><label class="boldtxt">Email:</label></td>
<td align="left" valign="middle" class="heightMid"><input type="text" name="email" id="email" />
</td>
</tr>
<tr>
<td align="left" valign="middle"><label class="boldtxt">Password:</label></td>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><input type="password" name="password" id='password' class="loginfld" />
</td>
<td align="left" valign="middle"><input type="image" src="img/submit.jpg" class="submit" onClick="return validation();" />
</td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"><a href="forget_password.php" class="normalTxt">Forgot your password?</a><br />
</td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><a href="provider_registration.php"><img src="images/applybut.jpg" alt="" border="0" class="apply" /></a></td>
</tr>
<tr>
<td align="left" valign="top">
<?=$value?>
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
</table>
</td>
</tr>
</table>
推荐答案
好的,您有一个带有文件名的echo语句:
ok, you have an echo statement with a file name:
echo "myaccount.php";
首先,您确定这是您想要做的吗?我相信它将回显字符串"myaccount.php".我相信您会希望包含"myaccount.php"
First of all, are you sure that is what you want to do? I believe that will echo the string "myaccount.php". I believe you would want to include "myaccount.php"
其次,您在javascript中引用了表单字段"user_name",但是您尝试访问的字段名称被命名为"email".这也可能是问题的一部分.
secondly, you have referenced the form field "user_name" in your javascript, but the field name you are trying to access is named "email". That might be part of the issue as well.
这篇关于登录脚本无法按要求运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!