PHP新闻添加源码

PHP新闻添加源码
PHP新闻添加源码

session_start();

if($_SESSION["admin_nc"]=="")

{

echo ""; exit;

}

include_once("../conn/conn.php");

if($_GET['action']=='add'){

$_html=array();

$_html['title']=trim($_POST['title']);

$_html['uid']=$_POST['uid'];

$_html['birth']=trim($_POST['birth']);

$up_file=$_POST['up_file'];

$_html['content']=trim($_POST['content']);

function getname($exname){

$dir = "upnewsimg/";

$i=1;

if(!is_dir($dir)){

mkdir($dir,0777);

}

while(true){

if(!is_file($dir.$i.".".$exname)){

$name=$i.".".$exname;

break;

}

$i++;

}

return $dir.$name;

}

$exname=strtolower(substr($_FILES['up_file']['name'],(strrpos($_FILES['up_file'] ['name'],'.')+1)));

$uploadfile = getname($exname);

move_uploaded_file($_FILES['up_file']['tmp_name'], $uploadfile);

if(trim($_FILES['up_file']['name']!=""))

{

$uploadfile="admin/".$uploadfile;

}

else

{

$uploadfile="";

}

/* echo $uploadfile; */

mysql_query("insert into tb_news

(news_title,news_type,news_aut,news_con,news_date,news_img) values('{$_html

['title']}','{$_html['uid']}','{$_html['birth']}','{$_html['content']}',now

(),'{$uploadfile}')");

echo"";

}

?>

"https://www.360docs.net/doc/cf223931.html,/TR/xhtml1/DTD/xhtml1-transitional.dtd">

添加新闻

添加新闻

  • 所属分类:

  • 新闻标题:
  • 作    者:

  • 新闻主题图片
  • 新闻内容:

mysql_close();

?>

相关主题
相关文档
最新文档