新手…小白在此
学了三天了,跟着视频写了个简单的,但是……
add.php文件:
<?php
本@文来源[email protected]搞@^&代*@码网(搞代gaodaima码
$conn=mysql_connect(“localhost”,”root”,”123″);
mysql_select_db(“test”,$conn);
if($_POST[‘send’])
{
if(mysql_query(“insert into totest(username,usertitle,usercontent,date)values(‘$_POST[user]’,’$_POST[title]’,’$_POST[content]’,now())”,$conn))
{
echo “发表成功”;
}
else echo(“Mysql error:”.mysql_error());
}
mysql_close();
?>
Html文件:
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<body>
用户:
标题:
内容:
数据库totest表:
userid username usertitle usercontent date
1 2011-11-18
2 2011-11-18
3 2011-11-18
…………
为什么中间的POST都不能取到值啊?
——解决方案——————–
$_POST[title]为$_POST[‘usertitle’]…..
要用你的input的name名字……
——解决方案——————–
你的表单是 name=”username” name=”usertitle” 而你的php $_POST[user]’,’$_POST[title]’,’$_POST[content] 能取到才怪了
——解决方案——————–
这不丢人!小疏漏而已