麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
从数据库显示数据和从post显示数据的区别
悬赏分:20 - 2007年08月15日

[php] <? function unhtml($matches ) { $str=$matches[2]; //$str = str_replace ( '&', '&', $str ); //$str = str_replace ( ''', '\'', $str ); //$str = str_replace ( '"', '\"', $str ); $str = str_replace ( '<', '<', $str ); $str = str_replace ( '>', '>', $str ); return $str; } function myhtml($str ) { $str = str_replace ( '<', '<', $str ); $str = str_replace ( '>', '>', $str ); $str = str_replace ( ' ', ' ', $str ); $str = str_replace ( "\r", '', $str ); $str = str_replace ( "\n", '
', $str ); return $str; } function myout(&$a) { if (is_array($a)) { array_walk($a,'out'); } else { $a = stripslashes($a); $a = str_replace('"', '"', $a); } } function myin(&$a) { if (is_array($a)) { array_walk($a,'myin'); } else { $a = addslashes($a); } } if (get_magic_quotes_gpc() != 1) { isset($_GET) ? myin($_GET) : ''; isset($_POST) ? myin($_POST) : ''; isset($_COOKIE) ? myin($_COOKIE) : ''; isset($_REQUEST) ? myin($_REQUEST) : ''; @extract($_GET, EXTR_SKIP); @extract($_POST, EXTR_SKIP); @extract($_COOKIE, EXTR_SKIP); @extract($_REQUEST, EXTR_SKIP); } if($action=="add"){ print'
文章内容
(必填)
' ; } if($action=="addnew") { include_once("../include/mysql.php"); //连接数据库 $db=new db; $db->obj["sql_user"]="root" ; $db->obj["sql_pass"]=""; $db->obj ["sql_host" ]="localhost"; $db->obj["sql_database"]="test"; $db-> connect(); $sql="insert into test set txt='$artext'"; $db->query($sql); print($artext); } if($action=="showart") { include_once("../include/mysql.php"); //连接数据库 $db=new db; $db->obj["sql_user"]="root" ; $db->obj["sql_pass"]=""; $db->obj ["sql_host" ]="localhost"; $db->obj["sql_database"]="test"; $db-> connect(); $sql="select * from test where id='$id'"; $db->query($sql); $info=$db->fetch_row(); print($info['txt']."
"); } if($action=="show") { include_once("../include/mysql.php"); //连接数据库 $db=new db; $db->obj["sql_user"]="root" ; $db->obj["sql_pass"]=""; $db->obj ["sql_host" ]="localhost"; $db->obj["sql_database"]="test"; $db-> connect(); $sql="select * from test"; $db->query($sql); while($info=$db->fetch_row()) { print "{$info['id']}
"; } } //$code=$artext; //myout($code); //$str=$code; //$str=myhtml($code); //$str=preg_replace_callback("/(\[php\])(.+?)(\[\\/php\])/is","unhtml",$str); print('test add   test show'); ?>[/php] 从文本框提交如下文本

CODE:
<table width="100%" border="0" cellspacing="1" cellpadding="2" style=" font-size:9pt"> <form enctype="multipart/form-data" method="post" action="t1.php?action=addnew" > <tr> <td width="10%" bgcolor="#999999" align="center">文章内容<br><FONT COLOR="#FF6600"><b>(必填)</b></FONT></td> <td width="90%" bgcolor="#999999"> <textarea name="artext" cols="80" rows="20" style="border:1px solid #333333"></textarea> </td> </tr> <tr > <td colspan="2" bgcolor="#CCCCCC"> <div align="center"> <input type="submit" name="post" value="发表"> <input type="reset" name="resert" value="重写"> </div> </td> </tr> </form> </table>

显示如下:

提问者:taita1973   08-15 15:03
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
0 + 72 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM