<? if (empty($_username))
{?>
<form name="form1" method="post" action="">
  <p>
    <input name="_username" type="text" id="_username">
</p>
  <p>
    <input name="_password" type="text" id="_password">
    <input type="submit" name="Submit" value="提交">
  </p>
</form>
 <? }
 else
 {
if ($_username=='abc' && $_password=='1') 
     echo "php成功登录,页面跳转中,请稍候……";
else  echo "用户名或密码不对,请重新输入";
}
?>//输出为 “php成功登录,页面跳转中,请稍候……”

解决方案 »

  1.   

    可能是你的_username和_password不对吧!其他末得啥问题列!
      

  2.   

    代码没什么错误,肯定传过来的值有误
    你先输出$_username, $_password看看
      

  3.   

    谢谢各位先!
    我用echo和print分别输出$_username,$_password,然后得到一个空白页面!代码如下:<?php
    print "$_username";//print or echo
    print "$_password";//print or echo
    ?>我的提交表单是这样的:<form action="login2.php" method="post">
    <TABLE width="450" border="0" align="center">
    <TR align="left">
    <TD height="30" width="27%" align="left">请登陆后查看</TD>
    <TD height="30" width="22%" align="center"> 用户名 </TD>
    <TD height="30" width="*" align="center"><input type="text" name="_username"/></TD>
    </TR>
    <TR align="left">
    <TD height="30" width="27%" align="left"></TD>
    <TD height="30" width="22%" align="center"> 密码 </TD>
    <TD height="30" width="*" align="center"><input type="text" name="_password"/></TD>
    </TR>
    <TR align="left">
    <TD height="30" width="27%" align="left"></TD>
    <TD height="30" width="22%" align="right"><input type="submit" value="登录"/></TD>
    <TD height="30" width="*" align="left"></TD>
    </TR>
    </TABLE>
    </form>然后的php处理页面就是上面的那个:<?php 
    if ($_username=='abc' && $_password=='1') 
         {echo "php成功登录,页面跳转中,请稍候……";} 
    else  {echo "用户名或密码不对,请重新输入";} 
    ?>我怎么也看不出了,大家帮看看啊!
      

  4.   

    $_POST['_username']
    $_POST['_password']
      

  5.   

    我把条件改成这样,还是不行啊?
    指教!if ($_POST['_username']=='abc' && $_POST['_password']=='1')
          {echo "php成功登录,页面跳转中,请稍候……";}
    else  {echo "用户名或密码不对,请重新输入";}
    ?>而且输出我也改啦!也不行!<?php
    print $_POST['_username'];
    print $_POST['_password'];
    ?>请指教!!!
      

  6.   

    谢谢大家,问题解决了,就是把
    $_POST['_username']  
    $_POST['_password'] 
    改成
    $_POST[_username]  
    $_POST[_password] 谢谢大家了,那我把分加了!