21,893
社区成员




if(isset($_POST[''])){
//执行数据库插入代码
}
conn=mysql_connect(localhost,root,123123);
mysql_select_db(netbook,$conn);
mysql_query("SET NAMES UTF8");
$sql="INSERT INTO chatroom (time,user,post) VALUES (now(),'".$_POST[user]."','".$_POST[post]."')";
mysql_query($sql);
mysql_close($conn);
$html=<<<HTML
<html>
<form name="form" action="a.php" method="post">
<table>
<tr><td>
<INPUT type="text" name="user" size="14" maxlength="14" value="" >
<INPUT type="text" name="post" size="80" maxlength="80" value="">
<INPUT type="submit" name="save" size="80" maxlength="80" value="Save">
</tr></td>
</table>
</form>
</html>
HTML;
echo $html;
<form name="form" action="a.php" method="post"></form>
提交可以用submit提交,也可以用button调用JS提交
<form name="form" action="a.php" method="post">
<input type="submit" name="sbt" value="提交">
</form>
<script>
function tijiao(){
window.form.submit();
}
<form name="form" action="a.php" method="post">
<INPUT type="text" name="user" size="14" maxlength="14" >
<INPUT type="text" name="post" size="80" maxlength="80" onclick="tijiao()">
</form>