然后下面就是: user.php ->接收数据并输出欢迎词
<?php
function err_output($errstr="未知错误!")
{
echo "<P ALIGN=CENTER><FONT COLOR=RED SIZE=4>
<B>$errstr<BR></B>请点击此处
<A HREF=javascript:history.go(-1);>返回</A></FONT></P>";
exit();
 }
$db = mysql_connect("localhost")
or err_output("无法连接数据库!");
mysql_select_db("users", $db)
or err_output("无法选择数据库!");
if(Submit1)
{
  if(empty($username)||empty($password))
  {
      err_output("用户名和密码均不能为空!");
   }
$result=mysql_query("select * from users where name='$username'");
   if (mysql_num_rows($rerult)!=1)
   {
      err_output("用户名不存在!");
    }
   else 
   {
$arruser=mysql_fetch_array($rerult);
      if ($arruser["password"]!=$password)
      {
err_output("你输入的密码不正确!");
      }
      else 
      {
setcookie($visited,$arrname["username"],time()+3600);
echo"<title>欢迎光临</title>";
echo"欢迎".$arruser["username"]."光临!";
       }
    }   
mysql_close($db);
exit();
}

解决方案 »

  1.   

    估计又是那种小问题了.
    PHP中的新版默认不再支持直接取变量, 而是从数组中取. 如用POST方式传表单, 就是用$_POST数组来取.
    如果想恢复旧版的用法, 在php.ini中设register_globals = On, 但极不推荐.
    建议楼上去www.php.net下载一本php手册, 慢慢看看
      

  2.   

    然后我点确定就什么都没有,就是没有接收到数据。
    不知道是怎么回事,请教各位高手帮小妹一下,我的QQ号是5156637(请注明CSDN)
    在此谢过!
      

  3.   

    但是我用的PHP4。3。1版的怎么算旧版啊。
      

  4.   

    使用 $username = $_POST["username"]得到变量值
    这是最安全的办法
    还可以入楼上的兄弟所说的办将php.ini的设为register_globals = On
      

  5.   

    请教 LeeMaRS(我不是情圣啊!555....)怎么样才能从新版中取数据啊?能否就这个例子讲一下,真心感谢!
      

  6.   

    在index.php中的
    <input type="submit" name="Submit2" value="重新填写" size="20">
    建议修改为
    <input type="reset" name="Reset" value="重新填写">
      

  7.   

    To  yy611612 (露珠儿)  
    送你一稿 源代码。希望对你有用,大家在学习上要互相帮助的:)如果你想要参考,我可以将程序打包 E-mail 给你。这是一个管理我自己工作的程序。" This is owm/add.php 添加数据 "<?php require_once('../Connections/php.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;  switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
    }if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO day (zh_title, zh_body, zh_fenlei, zh_dengji, zh_jzrq, zh_date) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($HTTP_POST_VARS['textfield_title'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['textfield_body'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['select_fenlei'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['select_dengji'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['textfield_jzrq'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['textfield_date'], "date"));  mysql_select_db($database_php, $php);
      $Result1 = mysql_query($insertSQL, $php) or die(mysql_error());  $insertGoTo = "list.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    ?>
     
    <html>
    <head>
    <title>添加新工作</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    .fonts {
    font-size: 11pt;
    }
    -->
    </style>
    </head><body leftmargin="0" topmargin="0" marginwidth="0">
    <table width="690" height="415" border="0" align="center" cellpadding="0" cellspacing="0" class="fonts">
      <tr> 
        <td width="690" height="50" align="center" bgcolor="#990000"><font color="#FFFFFF"><strong>The 
          Office Work Manager (Test)</strong></font></td>
      </tr>
      <tr> 
        <td height="50" bgcolor="#EAEAEA">  <a href="index.php">首页</a>&gt;正在添加一项新的工作......</td>
      </tr>
      <tr> 
        <td height="290"><form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
            <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" class="fonts">
              <tr> 
                <td>工作概要:</td>
                <td><input name="textfield_title" type="text" id="textfield_title2" size="50"></td>
              </tr>
              <tr> 
                <td width="23%">工作详情:</td>
                <td width="77%"><textarea name="textfield_body" cols="50" rows="9" id="textarea"></textarea> 
                </td>
              </tr>
              <tr> 
                <td>工作分类:</td>
                <td><select name="select_fenlei" size="1" id="select">
                    <option>网页风格设计</option>
                    <option>网页颜色设计</option>
                    <option>网页局部修改</option>
                    <option>网站Asp+Access数据库建设</option>
                    <option>网站Asp+SqlServer数据库建设</option>
                    <option>网站Php+MySql数据库建设</option>
                  </select></td>
              </tr>
              <tr> 
                <td>处理等级:</td>
                <td><select name="select_dengji" size="1" id="select2">
                    <option>正常工时 8 小时</option>
                    <option>加班工时 10 小时</option>
                    <option>加班工时 12 小时</option>
                  </select></td>
              </tr>
              <tr> 
                <td>加入时间:</td>
                <td><input name="textfield_date" type="text" id="textfield_date2">
                  (输入格式:2003-05-04 23:57)</td>
              </tr>
              <tr> 
                <td>截至时间:</td>
                <td><input name="textfield_jzrq" type="text" id="textfield_jzrq2"> 
                </td>
              </tr>
              <tr align="center" valign="bottom"> 
                <td height="25" colspan="2"><input type="submit" name="Submit" value="Insert work!">
                   
    <input type="reset" name="Submit2" value="Reset"> </td>
              </tr>
            </table>
            <input type="hidden" name="MM_insert" value="form1">
          </form></td>
      </tr>
      <tr> 
        <td height="25" bgcolor="#990000">&nbsp;</td>
      </tr>
      <tr>
        <td height="5" bgcolor="#999999"></td>
      </tr>
    </table>
    </body>
    </html>
    <?php
      mysql_free_result($Result1);
    ?>
      

  8.   

    关键在此:-> HTTP_POST_VARS['']
      

  9.   

    在php4.0及以上版本建议使用$_POST['']
      

  10.   

    去查查IIS的虚拟目录配置中,有.PHP吗?
      

  11.   

    我把$username=$_POST["username"];和$password=$_POST["passwprd"];
    加在user.php的开头部分,可是还是没有用啊,请教各位大哥是什么原因?
      

  12.   

    在加上这两句之后,试试用echo $username;echo $userpassword;看看变量传递过来没有
    我刚才在本地看,应该是传递过来了。
    同时 $db = mysql_connect("localhost")这一句有问题。
      

  13.   

    如果在  if($Submit1)之前加上echo $username;就可以输出数据;如果加在它下面就不能输出数据这是为什么?
      

  14.   

    加上$Submit=$_POST["Submit1"];试一试 :)
    你还是将 register_globals = On 打开吧