具体内容如下。
''''''''''''''''''''''
add.php
'''''''''''''''''''''''''''
<?php  include "config.inc.php"; ?>
<html><head>
<title>添加文章</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="common.css">
<script language="JavaScript">
<!--
function Juge(theForm)
{
if (theForm.title.value == "")
{
alert("请输入标题!");
theForm.title.focus();
return (false);
}
if (theForm.subkey.value == "" && theForm.newsubkey.value == "")
{
alert("请选择分类!");
theForm.detail.focus();
return (false);
}
if (theForm.detail.value == "")
{
alert("请输入内容!");
theForm.detail.focus();
return (false);
}
}
//-->
</script>
</head><body bgcolor="#FFFFFF"><p align="center">添加文章</p>
<form name="form1" method="post" action="add_ok.php" onsubmit="javascript:return Juge(this);">
  <div align="center">
    <center>
    <table border="0">
      <tr>
        <td width="100%" nowrap>标&nbsp;&nbsp;题:<input type="text" name="title" size="60" maxlength="80"><br>
            分&nbsp;&nbsp;类:<select size="1" name="subkey">
            <option selected>--请选择--</option>
<?php
$sqldo="select * from categorys order by name desc";
$result=mysql_query($sqldo);
if($result){
$rows=mysql_num_rows($result);
while($myrow=mysql_fetch_array($result)){
echo "            <option value=\"$myrow[name]\">$myrow[name]</option>\n";
}
}
?>
          </select>&nbsp;&nbsp;或新建:<input type="text" name="newsubkey" size="20"><br>
<?php
          $d_year=date("Y");
          $d_month=date("m");
          $d_day=date("d");
  echo "          来&nbsp;&nbsp;源:<input type=\"text\" name=\"source\" size=\"26\">&nbsp;&nbsp;添加时间:<input type=\"text\" name=\"d_year\" size=\"4\" value=$d_year>年<input type=\"text\" name=\"d_month\" size=\"2\" value=$d_month>月<input type=\"text\" name=\"d_day\" size=\"2\" value=$d_day>日<br>\n";
?>
          内&nbsp;&nbsp;容:<br>
          <textarea name="detail" rows="10" cols="68"></textarea><br>
          <input type="submit" name="add" value="提交"> <input type="reset" value="重填"> <input type="button" value="返回" onClick="history.back()"></td>
      </tr>
    </table>
    </center>
  </div>
</form></body></html>
''''''''''''''''''''
add_ok.php'''''''''''''''''''''
<?php  include "config.inc.php"; ?>
<html>
<head>
<title>提交成功</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="common.css">
</head>
<body bgcolor=#FFFFFF>
<?php
if ($add){    $title=htmlspecialchars($title);
    $mainkey=htmlspecialchars($mainkey);
    $subkey=htmlspecialchars($subkey);
    $source=htmlspecialchars($source);
    $detail=htmlspecialchars($detail);
//    $detail= str_replace ( "\n","<br>", $detail); 
if (checkdate($d_month,$d_day,$d_year) && $title) {
if ($newsubkey){
    $newsubkey=htmlspecialchars($newsubkey);
    $subkey=$newsubkey;
// $sqldo="insert into categorys (name) values ('$subkey')";
// $result=mysql_query($sqldo);
}
$add_time=$d_year."-".$d_month."-".$d_day." ".date("H").":".date("i").":".date("s");
$sqldo="insert into $temptable (title,detail,add_time,mainkey,subkey,source) values ";
$sqldo.="('$title','$detail','$add_time','$mainkey','$subkey','$source')";
$result=mysql_query($sqldo);
}
else {
$result=0;
$myerror = "日期错误!";
} echo "<div align='center'>";
    if ($result){
        echo "<p>提交成功!谢谢!如果内容有价值,管理员将会很快予以正式发布!<br><br>[ <a href='$homepage'>首页</a> <a href='$homepage?viewnew=1'>查看</a> <a href='add.php'>发布</a> ]</p>";
    }
    else{
        echo mysql_error();
        echo "<p>提交失败!$myerror <A href=\"JavaScript:history.back()\">返回</A></p>";
    }
    echo "</div>";
}
?>
</body>
</html>
谢谢你们回答

解决方案 »

  1.   

    <?
    if($add){
    $put1=$put;
    echo "$put";}
    else{
    echo "没有值!";}
    ?>
      

  2.   

    哦,估计你是php.ini里的register_globals=off的原因,把它改成register_globals=on
    不改也可以,采用新的写法,提交表单的接收方式为:$_POST['变量名']
      

  3.   

    建议register_globals的值不要设置成on。因为PHP以后的版本都将register_globals=off设为默认值,打开的话可能存在安全隐患。所以我认为还是用$_POST['变量名']或$_GET['变量名']来接收变量,当然,用哪个取决于<form method="">中method的决定,如果method="POST",就可用$_POST['变量名']接收,反之用$_GET['变量名'],最后,如果不知道是POST还是GET方法时,可试用$_REQUEST['']。
      

  4.   

    <?
    if($add){
    $put1=$_POST['$put'];
    echo "$put1";}
    else{
    echo "没有值!";}
    ?>