|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
<?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> </table> </form> </body> </html> 返回类别: 教程 上一教程: 浅谈PHP语法(5) 下一教程: 有几位朋友面临选择ASP还是PHP的问题,这是从PHP。NET上摘来的一些东西。php .vs. asp 您可以阅读与"这是我在做的一个系统中的新闻增加程序,可以上传图片,也可以输入绝对大于4K的内容(在textarea中),..."相关的教程: · 图片上传的一个例子 · PHP中如何增加一个系统用户 · 这是我在Linux 6.2下APACHE+PHP4+MYSQL的安装脚本。大家看看吧!写得很简陋,不过简化了我的不少工作。 · 一个简朴的(也可以说是不完全的)IMAP类和应用。(三) · 一个简朴的(也可以说是不完全的)IMAP类和应用。(二) |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |