我作的页面提交数据写到MYSQL数据库中并显示出来的程序

0 views
Skip to first unread message

love0...@gmail.com

unread,
Mar 21, 2006, 11:55:54 PM3/21/06
to 52info
INDEX.HTML代码
<form action="msg.php" method=POST>

<input type=text name=name>
<input type=text name=msg>
<input type=submit>
</form>


MSG.PHP
<?php
mysql_connect("localhost", "root", "windows") or
die("Could not connect: " . mysql_error());
mysql_select_db("php");

mysql_query("insert into msg values('$_POST[name]','$_POST[msg]')");

?>

<script language=javascript>
top.location="showmsg.php";
</script>

SHOWMSG.PHP
<?php
mysql_connect("localhost", "root", "windows") or
die("Could not connect: " . mysql_error());
mysql_select_db("php");
$result = mysql_query("select * from msg");

while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
echo $row[0].'<br>';
echo $row[1].'<br>';

}

mysql_free_result($result);

?>

Reply all
Reply to author
Forward
0 new messages