Page 1/2 of source code (3) of a php Forum program imitating oso
Last Update:2018-12-08
Source: Internet
Author: User
Procedure 3: readforum. php
<HTML>
<HEAD>
<TITLE> Forum Information </TITLE>
<Link rel = "STYLESHEET" type = "text/css" href = "fp_zhangcg.css">
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta name = "Microsoft Theme" content = "none">
<Meta name = "Microsoft Border" content = "none">
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
</HEAD>
<Body bgcolor = "# C0C0C0" background = "backcolor. GIF">
<?
Include ("c: mydbheader. inc ");
?>
<? Php
// Complete the function:
// Echo $ username;
// Echo $ useremail;
// Echo $ userhttp;
// Echo $ forumtitle;
// Echo $ fouumface;
// Echo $ forumcontent;
// Echo $ theme_id;
Echo 'G _ username: '. $ GLOBALS ["g_username"]. 'Is OK ';
$ Dbh = mysql_connect ('localhost: 100', 'root ','');
Mysql_select_db ('test ');
If (empty ($ readflag )){
$ Readflag = 0;
}
If ($ readflag> 0 ){
$ Theme_id = $ readflag;
}
If (empty ($ theme_id )){
$ Theme_id = 0;
}
// Echo $ username;
// Echo $ useremail;
// Echo $ userhttp;
// Echo $ forumtitle;
// Echo $ fouumface;
// Echo $ forumcontent;
If ($ readflag = 0) and ($ theme_id = 0) {// Add data
If (empty ($ username )){
Print "error. Check the data ";
}
$ Res = mysql_query ("SELECT max (id) + 1 AS rid FROM fr_t_forumtitle", $ dbh );
$ Row = mysql_fetch_array ($ res );
If (empty ($ row ["rid"]) {
$ Theme_id = 1;
} Else {
$ Theme_id = $ row ["rid"] + 1;
}
$ Tempstr = "insert into fr_t_forumtitle (id, state, readcount, replycount, title ,";
$ Tempstr = $ tempstr. "createman, replytime )";
$ Tempstr = $ tempstr. "values (". $ theme_id. ", '0', 0,-1 ,'". $ forumtitle. "','". $ username. "', now ());";
$ Res = mysql_query ($ tempstr, $ dbh );
}
If ($ readflag = 0 ){
$ Forumcontent = nl2br ($ forumcontent );
$ Tempstr = "insert into fr_t_forumcontent (id, content, replyman, replyemail ,";
$ Tempstr = $ tempstr. "replyhttp, replytime, replyface )";
$ Tempstr = $ tempstr. "values (". $ theme_id. ", '". $ forumcontent. "', '". $ username ."','".
$ Useremail. "','". $ userhttp. "', now (),". $ forumface .");";
$ Res = mysql_query ($ tempstr, $ dbh );
$ Tempstr = "update fr_t_forumtitle set readcount = readcount + 1, replycount = replycount + 1 ,";
$ Tempstr = $ tempstr. "replytime = now (), replyman = '". $ username. "'where id =". $ theme_id;
$ Res = mysql_query ($ tempstr, $ dbh );
} Else {
$ Tempstr = "update fr_t_forumtitle set readcount = readcount + 1 where id =". $ theme_id;
$ Res = mysql_query ($ tempstr, $ dbh );
}
?>
<Table width = "100%" border = "0">
<Tr class = "text">
<Td width = "50%"> <div align = "left"> current location: Home Page -- Forum content </div> </td>
<Td width = "50%"> <div align = "center"> & nbsp </div> </td>
</Table>
<?
$ Tempstr = "select title, readcount, replycount from fr_t_forumtitle where id =". $ theme_id;
$ Res = mysql_query ($ tempstr, $ dbh );
$ Row = mysql_fetch_array ($ res );
$ Ls_theme_title = $ row ["title"];
$ Li_readcount = $ row ["readcount"];
$ Li_replycount = $ row ["replycount"] + 1;
?>
<Table width = "100%" border = "0">
<Tr>
<Td width = "61%" class = "text"> topic: <span class = "text"> <font color = "# ff0000">
<?
Print $ ls_theme_title;
?>
</Font> </span> </td>
& Lt; td width = "13%" & gt;
<Div align = "center"> <a href = "addforum. php? Theme_id = 0 "target =" _ top "> </a> </div>
</Td>
& Lt; td width = "13%" & gt;
<?
Print '<div align = "center"> <a href = "addforum. php? Theme_id = '. $ theme_id .'"';
Print 'target = "_ top"> Print 'alt = "Reply to post" border = "0"> </a> </div> ';
?>
</Td>
& Lt; td width = "13%" & gt;
<Div align = "center"> <a href = "mainforum. php "target =" _ top "> </ a> </div>