Forum Moderators: coopster

Message Too Old, No Replies

Forums script - output to HTML

         

Kootch

7:12 pm on Jul 11, 2008 (gmt 0)

10+ Year Member



I'm looking for a quick and easy script that someone can:
- post short content in 3 or 4 different input boxes.
- the content would be posted in output on an HTML page.

Basically, for our website, we want to go out and find media links from daily online newspapers daily on a specific sport. Each day we'd find those links, copy the link location, title, and newspaper name, and post them in a php form. The output would show on the front page of our site.

I hope that makes sense? There's got to be scripts that do something similar - anyone with ideas?

eelixduppy

7:28 pm on Jul 11, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld! :)

You might be interested in a CMS for something like this. It will have the features that you need and more. Check [opensourcecms.com...] for most of the CMS that you'd use. I'd suggest Wordpress, but there are others that would work, too. Take a look and if nothing suits your needs or if they are "too much" for what you need you can role your own code, in which case we have a few threads in our library that could help you out: Library [webmasterworld.com].

Good luck :)

Kootch

7:30 pm on Jul 11, 2008 (gmt 0)

10+ Year Member



Thanks for the quick response.

Actually I use Wordpress right now as a CMS - love it.

I just want an external FORMS php script that I can paste into the form and it outputs to an HTML file, which I can insert easily into the Wordpress sidebar as a module.

eelixduppy

7:54 pm on Jul 11, 2008 (gmt 0)



So you can just prepend the links to a HTML-formatted file that doesn't need to be a full HTML document as it's being included in another document?

So let's say you have the following form somewhere:


<form action="add_news.php" method="post">
Title<input type="text" name="title" /><br />
URL<input type="text" name="url" /><br />
Newspaper<input type="text" name="newspaper" /><br />
<input type="submit" />
</form>

And then on the add_news.php page, you could do something like this:


$news_file = '/path/to/news.html'; # file to write to
if(![url=http://www.php.net/is-file]is_file[/url]($news_file) ¦¦ ![url=http://www.php.net/isset]isset[/url]($_POST)) [url=http://www.php.net/die]die[/url];
#
# get POSTed data
$title = [url=http://www.php.net/htmlentities]htmlentities[/url]($_POST['title']);
$url = htmlentities($_POST['url']);
$newspaper = htmlentities($_POST['newspaper']);
#
# format HTML for inclusion in file using heterdoc syntax
$html =<<<HTML
<h3><a href="$url" title="Click to news source">$title</a></h3>
<p><i>Source: $newspaper</i></p>
<hr>
HTML;
#
$content = [url=http://www.php.net/file-get-contents]file_get_contents[/url]($news_file);
$handle = [url=http://www.php.net/fopen]fopen[/url]($news_file, 'w');
[url=http://www.php.net/fwrite]fwrite[/url]($handle, $html); #add new content
fwrite($handle, $content); #add existing content back
[url=http://www.php.net/fclose]fclose[/url]($handle);

Try that and tweak it to fit yours needs. It certainly will get you started.