首 页文章中心客户留言enfullPDA完全版游戏天空全方位下载繁體中文
设为首页
加入收藏
联系我们
您当前的位置:技术文章大全 -> 文章中心 -> 技术开发 -> PHP学院 -> 文章内容 退出登录 用户管理
栏目导航
· .Net专栏 · Script
· ASP学院 · PHP学院
· Web服务器 · XML学院
· SQL学院 · JSP学院
· 程序开发 · 数据库
热门文章
· 个人实习总结
· “八荣八耻”演讲稿...
· 毕业论文格式范文
· 八荣八耻 内容|八荣...
· 党校学习个人总结
· “八荣八耻”心得体...
· 教育实习总结报告
· 社会主义荣辱观教育...
· 市场营销系毕业实习...
· 党课学习思想汇报
相关文章
· 这是我在网上摘入的...
· 这是我在Linux 6.2下...
这是我在做的一个系统中的新闻增加程序,可以上传图片,也可以输入绝对大于4K的内容(在textarea中),...
作者:佚名  来源:不详  发布时间:2006-1-8 18:41:57  发布人:admin

减小字体 增大字体

<?php
/*******所用到的表结构********
DROP TABLE IF EXISTS index_news;
CREATE TABLE index_news (
 news_id bigint(20) NOT NULL auto_increment,
 news_date date DEFAULT '0000-00-00' NOT NULL,
 news_title varchar(100) NOT NULL,
 news_content text,
 news_link varchar(100),
 is_new char(1) DEFAULT '1',
 picture_id int(11),
 picture_side char(1) DEFAULT '1',
 news_show char(1) DEFAULT '1',
 PRIMARY KEY (news_id),
 KEY id (news_id)
);
DROP TABLE IF EXISTS picture;
CREATE TABLE picture (
 id int(11) NOT NULL auto_increment,
 picture blob NOT NULL,
 picture_type varchar(50) NOT NULL,
 PRIMARY KEY (id),
 UNIQUE id (id)
);
**********************/
require("../include/date.inc.php3");
require("../include/config.inc.php3");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>修改首页新闻信息</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v3.0
var p,i,x;if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_validateForm() { //v3.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; obj_name=args[i+1]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+obj_name+' 必须是一个E-Mail地址.\n';
} else if (test!='R') { num = parseFloat(val);
if (val!=''+num) errors+='- '+obj_name+' 必须是一个数字.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+obj_name+' 必须是一个在 '+min+' 和 '+max+'之间的数字.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+obj_name+' 必须输入.\n'; }
} if (errors) alert('输入数据存在错误:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>
<?php
if ($add){
$date=input2date($news_date);
//echo $picture . "". filesize($picture);
//if ($is_new!="0") $is_new="1" ;
//if ($news_show!="0") $news_show="1";
//if ($picture_side!="2") $picture_side="1";
if ($picture!="none"){
$pic_data = addslashes(fread($fp=fopen($picture,"r"), filesize($picture)));
$i_str="insert into picture (picture,picture_type) values ('$pic_data','$picture_type')";
//$rs->open($i_str);
$result=mysql_query($i_str,$dbconnect);
$picture_id=mysql_insert_id();
fclose($fp);
unlink($picture);
}
else{
$picture_id=0 ;
}
$i_str="insert into index_news (news_date,news_title,news_content,news_link,picture_id,is_new,picture_side,news_show) values ";
$i_str.="('$date','$news_title','$news_content','$news_link','$picture_id','$is_new','$picture_side','$news_show') ";

if (mysql_query($i_str,$dbconnect)) echo "已添加!";

}

<form name="F" enctype="multipart/form-data" method="post" action="<?php echo $PATH_INFO; ?>" >
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="2">
<div align="center"><font size="4">增加新闻信息</font></div>
</td>
</tr>
<tr>
<td colspan="2">  </td>
</tr>
<tr>
<td width="100">新闻标题: </td>
<td>
<input type="text" name="news_title" size="60">
</td>
</tr>
<tr>
<td>新闻内容:</td>
<td>
<textarea name="news_content" cols="58" rows="5"></textarea>
</td>
</tr>
<tr>
<td>新闻日期:</td>
<td>
<input type="text" name="news_date">
(日期请按照2000-01-02格式输入) </td>
</tr>
<tr>
<td>新闻链接:</td>
<td>
<input type="text" name="news_link" size="60">
</td>
</tr>
<tr>
<td>是否最新:</td>
<td>
<select name="is_new">
<option value="1" selected>是最新</option>
<option value="0">不是最新</option>
</select>
</td>
</tr>
<tr>
<td>新闻图片:</td>
<td>
<input type="file" name="picture" size="50">
</td>
</tr>
<tr>
<td>图片位置:</td>
<td>
<select name="picture_side">
<option value="1" selected>左边</option>
<option value="2">右边</option>
</select>
</td>
</tr>
<tr>
<td>是否显示:</td>
<td>
<select name="news_show">
<option value="1" selected>显示</option>
<option value="0">不显示</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="add" value="增加" onClick="MM_validateForm('news_title','','R','news_date','','R','news_content','','R');return document.MM_returnValue">
<input type="button" name="return" value="返回">
<input type="reset" name="reset" value="重新输入">
</div>
</td>
</tr>

</form>
</body>
</html>
[] [返回上一页] [打 印] [收 藏]
下一篇文章:ASP分页显示之乱盖
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
友情连接 - 网站地图 -