invisionx Posted July 8, 2007 Share Posted July 8, 2007 I found this News script which is flatfile and well I want to add a name and date to it so that when I or one of my friends posts a new news post they can put there names on it can someone help me ill show both the form for the New Post News and for the save.. New Post <form action="<?=$_SERVER['PHP_SELF'] ?>" method="POST"> Name: <input name="nname" type="text" size="25" maxlength="50"> <input name="date" type="text" value="<?php echo date("F j, Y, g:i a"); ?>" size="23" maxlength="100" readonly="true"><br> News: <textarea style="width:500px;height:150px" wrap=PHYSICAL name="text"></textarea> </TD> <TD WIDTH=40></TD> <TD WIDTH=110 align=right valign=middle> <input type=hidden name=action value="save" /> <input type=hidden name=nr value="new" /> <input style="width:100px" type="submit" value="Save" /> </form> <form action="<?=$_SERVER['PHP_SELF'] ?>" method="POST"> <input type=hidden name=action value="show" /> <input style="width:100px" type="submit" value="Back" /> </form> Save if ( $action == 'save' || $save ) { $nname = trim($nname); $text = trim($text); if (!empty($text)) { $text = ereg_replace("\\\'", "'", $text); // make the quotes visible ' --> ' $text = ereg_replace('\\\"', '"', $text); // remove escaping from doublequotes \" $text = ereg_replace("\n", '<br>', $text); // linefeed / breakline ... ($nr =='new')? $news[] = $text : $news[$nr] = $text; save_news(); } Thank you invisionx Link to comment https://forums.phpfreaks.com/topic/58890-flatfile-news-help/ Share on other sites More sharing options...
pocobueno1388 Posted July 8, 2007 Share Posted July 8, 2007 Well, I don't see anywhere in your script where it inserts anything into a flat file. I see that you have a function called save_news(), maybe that is where you save it to the file? Could you post the code to that function? Link to comment https://forums.phpfreaks.com/topic/58890-flatfile-news-help/#findComment-292195 Share on other sites More sharing options...
invisionx Posted July 8, 2007 Author Share Posted July 8, 2007 function save_news() { global $news; ksort ($news); $data = serialize(array_values($news)); $fp = fopen(DATA_FILE,"w+"); fputs($fp,$data); fclose($fp); header("Location: ".$_SERVER['PHP_SELF']."?action=show"); // Stop the reload problem } Link to comment https://forums.phpfreaks.com/topic/58890-flatfile-news-help/#findComment-292196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.