Jump to content

FlatFile News Help


invisionx

Recommended Posts

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("\\\'", "&#39;", $text);		// make the quotes visible ' --> &#039;
		$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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.