日期:2014-05-17 浏览次数:20380 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form action="insert.php" method="post" target="win">
请输入新闻的title:<input type="text" name="title" />
请选择新闻类型:<select name="c_id"><option value="1">体育</option><option value="2">娱乐</option></select>
<br />
请输入新闻的content:<br />
<textarea cols="60" rows="15" name="content"></textarea>
<input type="submit" value="提交" />
</form>
</body>
</html>
<?php
include("connect_mysql.php");
$q = "insert into new(title,content,time,news_cate_id) values('".$_POST["title"]."','".$_POST["content"]."',now(),".$_POST["c_id"].")";
mysql_query($q);
if(mysql_affected_rows()>0) echo "xinwentianjiachenggong!";
?>
<hr />
<a href="add_news.php" target="win">fanhuijixutianjiaxinwen</a>
<?php
function mysql_open()
{
$mysql_servername="localhost"; //
$mysql_username="root";
$mysql_password="11111";
$mysql_dbname="new";
$conn=mysql_connect($mysql_servername ,$mysql_username ,$mysql_password);
mysql_query("set names UTF8"); //UTF8
mysql_select_db($mysql_dbname , $conn);
return $conn;
}
?>