level 5
做留言板,准备用if判断后插入,但是做好以后if($_POST["submit"]不判断。没办法插入啊。也没提示,怎么回事?
2014年05月30日 15点05分
1
level 10
submit不是提交按钮吗 它穿过来的应该是name值
2014年05月30日 16点05分
2
判断这个不是不用写后面的值么?我看视频上直接就这么写的也能判断,可我的就不判断。
2014年05月31日 00点05分
<form action="" method='post'> <input type="text" name='username' value=""> <input type="submit" value='提交'> <button type='submit'> 提交</button></form><?php $user=$_POST['username']; ?>
2014年05月31日 04点05分
回复 膝搏盖卡秃噜皮 :我把全部的贴出来了,还是不行,你看一下对么?
2014年05月31日 05点05分
回复 HHQQ_夹子 :我要看一下你的html 代码 才行我不知道你的name 值什么吗?
2014年05月31日 09点05分
level 8
要定义submit的name名然后POST传的是名
2014年05月31日 00点05分
3
意思是if($_POST["submit"]=="name"){....}这个样子?
2014年05月31日 02点05分
就是和其他一样用名字接收,起个名字
2014年05月31日 03点05分
回复 你偌成風不虚无 :我把全部的贴出来了,还是不行,你看一下对么?
2014年05月31日 05点05分
level 7
<input type="submit" name="submit" value="提交" /> 用这个按钮就可以了
2014年05月31日 02点05分
5
我把全部的贴出来了,还是不行,你看一下对么?
2014年05月31日 05点05分
level 10
<form action="" method='post'>
<input type="text" name='username' value="">
<input type="submit" value='提交'>//submit 也是提交按钮也是不用传过来值得
<button type='submit'> 提交</button>//button也是提交按钮 它不用传过来值的
</form>
<?php
$user=$_POST['username'];
?>
2014年05月31日 04点05分
6
我把全部的贴出来了,还是不行,你看一下对么?
2014年05月31日 05点05分
level 5
我把全部贴出来。
conn.php
<?php
/*
* Created on 2014-5-29
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("new", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>
add.php
<?php
/*
* Created on 2014-5-29
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include('conn.php');
if($_POST['subimt']){
$sql="insert into message (id,user,title,content,lastdate)" .
"values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql,$conn);
echo "发布成功";
?>
<form action="add.php" method="post" >
用户:<input type="text" size="10" name="user" /><br/>
标题:<input type="text" name="title" /><br/>
内容:<textarea name="content"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form>
你们看一下我写的对么?
就是这些,可是怎么也插入不了信息。
2014年05月31日 05点05分
7
level 7
我把全部贴出来。
conn.php
<?php
/*
* Created on 2014-5-29
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("new", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>
add.php
<?php
/*
* Created on 2014-5-29
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include('conn.php');
if($_POST['submit']){
$sql="insert into message (id,user,title,content,lastdate)" .
"values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql,$conn);
echo "发布成功";
?>
<form action="add.php" method="post" >
用户:<input type="text" size="10" name="user" /><br/>
标题:<input type="text" name="title" /><br/>
内容:<textarea name="content"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form>
2014年05月31日 05点05分
8
回复 简单1003314741 :改的哪呢?
2014年05月31日 05点05分
回复 HHQQ_夹子 :把$_POST['subimt']改成$_POST['submit']了
2014年05月31日 05点05分
回复 简单1003314741 :太谢谢拉!!!!!!!!!!!!看的我都晕了。
2014年05月31日 05点05分