在else部分引号有问题,改了一下,再试试<html>
<body>
<?php
if($submit)
{
while(list($name,$value)=each($HTTP_POST_VARS))
{
echo "$name=$value<br>\n";
}
//处理表格输入
$db=mysql_connect("localhost","root","root");
mysql_select_db("lwx",$db);
$sql="INSERT INTO employees(first,last,address,position)
VALUES ('$first','$last','$address','$position')";
$result=mysql_query($sql);
echo "信息加入数据库。\n";}
else{
?>
<form method="post" action="<?php echo $PATH_INFO?>">
名:<input type="Text" name="first" value="fuck1"><br>
姓:<input type="Text" name="last" value="fuck1"><br>
住址:<input type="Text" name="address" value="fuck1"><br>
职位:<input type="Text" name="position" value="fuck1"><br>
<input type="submit" name="submit" value="输入a信">
</form>
<?php
}
?>
</body>
</html>
<body>
<?php
if($submit)
{
while(list($name,$value)=each($HTTP_POST_VARS))
{
echo "$name=$value<br>\n";
}
//处理表格输入
$db=mysql_connect("localhost","root","root");
mysql_select_db("lwx",$db);
$sql="INSERT INTO employees(first,last,address,position)
VALUES ('$first','$last','$address','$position')";
$result=mysql_query($sql);
echo "信息加入数据库。\n";}
else{
?>
<form method="post" action="<?php echo $PATH_INFO?>">
名:<input type="Text" name="first" value="fuck1"><br>
姓:<input type="Text" name="last" value="fuck1"><br>
住址:<input type="Text" name="address" value="fuck1"><br>
职位:<input type="Text" name="position" value="fuck1"><br>
<input type="submit" name="submit" value="输入a信">
</form>
<?php
}
?>
</body>
</html>
$submit=$HTTP_POST_VARS['submit'];
这个时候再次判断$submit变量的时候,就会进入if语句了。这里我注释了if语句的其他内容,具体的接收其他变量的工作就要由楼主自己做喽~~~~:)<html>
<body>
<?php
$submit=$HTTP_POST_VARS['submit'];
if($submit)
{
echo "ififif";
//while(list($name,$value)=each($HTTP_POST_VARS))
// {
// echo "$name=$value<br>\n";
// }
////处理表格输入
//$db=mysql_connect("localhost","root","root");
//mysql_select_db("lwx",$db);
//$sql="INSERT INTO employees(first,last,address,position)
//VALUES ('$first','$last','$address','$position')";
//$result=mysql_query($sql);
//echo "信息加入数据库。\n";}
else{
?>
<form method="post" action="<?php echo $PATH_INFO?>">
名:<input type="Text name="first" value="fuck1"><br>
姓:<input type="Text name="last" value="fuck1"><br>
住址:<input type="Text name="address" value="fuck1"><br>
职位:<input type="Text name="position" value="fuck1"><br>
<input type="submit" name="submit" value="输入a信">
</form>
<?php
}
?>
</body>
</html>
代表fans197719 (阿呆) 感谢各位
马上结贴
再次感谢syp8065(小妹请求支援)的帮助
还会有很多问题向各位请教的
再给50分
http://expert.csdn.net/Expert/topic/2033/2033838.xml?temp=.2732813