-3

可能重复:
登录脚本未按要求工作

这是一个与我的代码一起重复的新问题

这是我的代码

<?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>";
}
}
?>

请任何人都可以帮助我我花了很多时间都没有成功

这是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">&nbsp;</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">&nbsp;</td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">&nbsp;</td>
                    </tr>
                </table>
          </td>
        </tr>
      </table>

现在有人可以帮我解决这个问题吗?

4

1 回答 1

0

你能包括你的问题的原始背景吗?什么是错误/不正确的行为?这是托管在某个地方进行测试吗?

据我所知,它不是基于成功登录重定向

if(empty($error)){
    echo "myaccount.php";
}

此行仅输出“myaccount.php”。我相信如果您更改空($error)检查以包含重定向,它应该可以工作。

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;

        /* Redirect user if successful login */
        header('Location: myaccount.php');
    } else {
        $error .= "Please check Email and Password.";
}
于 2012-11-15T16:33:56.123 回答