Notice: Undefined index: submit in *
时间:2010-08-29
来源:互联网
在调试php程序时出现Notice: Undefined index: submit in D:\www\chat\add.php on line 26
并且<?php=$row[username]?>,<?php=$row[utitle]?>,<?php=$row[ucon]?>,<?php=$row[remake]?>现实不出来。
请高手指点,以下是源码:
----这个提交页面----
<?php
include("conn.php");
if($_POST['submit']){
$sql="insert into chat (id,username,utitle,ucon,remake) values ('','$_POST[username]','$_POST[utitle]','$_POST[ucon]',now())";
mysql_query($sql);
echo"发表成功";
}
?>
<div id="wrap">
<h1>添加留言</h1>
<form action="add.php" method="post">
<table cellpadding="0" cellspacing="1" class="Table">
<tr>
<th>用户名:</th>
<td><input name="username" type="text" class="input" /></td>
</tr>
<tr>
<th>标题:</th>
<td><input name="utitle" type="text" class="input" /></td>
</tr>
<tr>
<th valign="top">内容:</th>
<td><textarea name="ucon" type="text" /></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" value="提交" class="btn" /></td>
</tr>
</table>
</form>
</div>
----这是现实页面---
<?php
include("conn.php");
?>
<h1>留言板</h1>
<?php
$sql="select * from chat";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){
?>
<dl>
<dt>标题:<?php=$row[utitle]?><span>用户名:<em><?php=$row[username]?></em>时间:<?php=$row[remake]?></span></dt>
<dd><?php=$row[ucon]?></dd>
</dl>
<?php
}
?>
并且<?php=$row[username]?>,<?php=$row[utitle]?>,<?php=$row[ucon]?>,<?php=$row[remake]?>现实不出来。
请高手指点,以下是源码:
----这个提交页面----
<?php
include("conn.php");
if($_POST['submit']){
$sql="insert into chat (id,username,utitle,ucon,remake) values ('','$_POST[username]','$_POST[utitle]','$_POST[ucon]',now())";
mysql_query($sql);
echo"发表成功";
}
?>
<div id="wrap">
<h1>添加留言</h1>
<form action="add.php" method="post">
<table cellpadding="0" cellspacing="1" class="Table">
<tr>
<th>用户名:</th>
<td><input name="username" type="text" class="input" /></td>
</tr>
<tr>
<th>标题:</th>
<td><input name="utitle" type="text" class="input" /></td>
</tr>
<tr>
<th valign="top">内容:</th>
<td><textarea name="ucon" type="text" /></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" value="提交" class="btn" /></td>
</tr>
</table>
</form>
</div>
----这是现实页面---
<?php
include("conn.php");
?>
<h1>留言板</h1>
<?php
$sql="select * from chat";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){
?>
<dl>
<dt>标题:<?php=$row[utitle]?><span>用户名:<em><?php=$row[username]?></em>时间:<?php=$row[remake]?></span></dt>
<dd><?php=$row[ucon]?></dd>
</dl>
<?php
}
?>
作者: hunkin007 发布时间: 2010-08-29
你这样的写法应该是<?=$row['utitle']?>而且要从php.ini里,吧short_open_tag设为On
或者,老老实实写<?php echo $row['utitle'];?>
至于那个notice如果不想看到,可以在开始处设置error_reporting(E_ERROR | E_WARNING | E_PARSE);
或者,老老实实写<?php echo $row['utitle'];?>
至于那个notice如果不想看到,可以在开始处设置error_reporting(E_ERROR | E_WARNING | E_PARSE);
作者: tochenwei 发布时间: 2010-08-29
引用
引用第1楼tochenwei于2010-08-29 12:31发表的 :
你这样的写法应该是<?=$row['utitle']?>而且要从php.ini里,吧short_open_tag设为On
或者,老老实实写<?php echo $row['utitle'];?>
至于那个notice如果不想看到,可以在开始处设置error_reporting(E_ERROR | E_WARNING | E_PARSE);
你这样的写法应该是<?=$row['utitle']?>而且要从php.ini里,吧short_open_tag设为On
或者,老老实实写<?php echo $row['utitle'];?>
至于那个notice如果不想看到,可以在开始处设置error_reporting(E_ERROR | E_WARNING | E_PARSE);
<?php echo $a?>或<?=$a?>你写错了。NOTICE没影响。
作者: element 发布时间: 2010-08-29
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28