<?php if($_POST['submit']){
  echo "登入成功";
 
 }
?>  <form action="login.php" method="post" enctype="text/plain">
  用户名:<input type="text" name="user" size="10">
  密码:<input type="password" name="pass" size="10">
<input type="submit" name="submit"  value="登入" size="10">
  </form> 点击登入后没有显示“登入成功”,这是为什么呢?小弟刚学php,望高手赐教!

解决方案 »

  1.   


    $_POST['submit']改成$_SERVER['REQUEST_METHOD'] == 'POST'  试试
      

  2.   

    如果不确定,可以print_r($_POST);看看传过来什么
      

  3.   


    在if($_POST['submit'])前加了print_r($_POST);输出Array()     这是什么意思呢?    
    还有个问题:输出Array()是在我点击“登入”前就有了,这是为什么呢?还没提交表单哪来$_POST?   
      

  4.   

    Array()表示print出来的是一个数组,而且是一个空数组。
    $_POST是系统预定义的数组变量,你没有点登陆,只是没有往$_POST里面写值,但是$_POST已经存在了。多看看PHP手册。
      

  5.   

    你取值失败的原因把enctype="text/plain" 删掉form表单传数据大概三种方式,有兴趣你去GOOGLE搜索了解
      

  6.   

    <form action="login.php" method="post" enctype="text/plain">
    把提交类型去掉 enctype 试试。
      

  7.   

    谢谢amani11,把enctype="text/plain" 删掉可以提交表单了,但是还有个问题:enctype="text/plain"是什么意思,起了什么作用?
      

  8.   

    我又添加了session_start();出现如下错误提示:Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Software     请问这是什么问题?
      

  9.   

    Warning的意思是,session_start();之前,不要有任何输出。你可以
    <?php
    //这一行添加session_start();试试
      

  10.   

    看了这个你应该知道是什么作用<html> <body bgcolor=wheat><form method=post
    action="mailto:[email protected]?subject=Testing submit"
      enctype="text/plain" >Please fill in your name:
    <input type=text size=20 name="Visitor" > <p>Please fill in your telephone number:
    <input type=text size=20 name="Tel" > <p><input type=submit value="Submit information" >
    <input type=reset value="Clear filled data" >
    </form>
    </body> </html>
      

  11.   

    application/x-www-form-urlencoded
    在发送前编码所有字符(默认)multipart/form-data 
    不对字符编码。
    在使用包含文件上传控件的表单时,必须使用该值。text/plain 
    空格转换为 "+" 加号,但不对特殊字符编码。(用$_REQUEST应该能取到值)