|
|
|
News
Posting System
Create a new PHP document called add.php. On this page create
a form which can be used to type the news. The Form I have
showed as an example is only set for Title, News, Poster, and
Submit. If your expeirenced you can modify the fields, but
remember if you modify the form you must also modify the php.
CODE |
<FORM action="added.php"
method="POST">
Title:<INPUT TYPE="TEXT"
name="title"><br>
News:<TEXTAREA WRAP=VIRTUAL NAME="news"
COLS=20 ROWS=5> Nice Site! </TEXTAREA><br>
Posted by:<INPUT TYPE="text"
name="poster"><br>
<INPUT TYPE="SUBMIT"
name="submit" value="submit">
</FORM>
|
Create a new page called added.php which will be
telling the form what to do.
CODE |
<?php
$da = getdate();
$date="$da[weekday] $da[mday] $da[month] $da[year]";
$news = ("<font size=\"2\"
face=\"Tahoma\">
<b>$title</b> //form text box named title
<br>
$news //form text box named news (get it?)
<br>
Posted by: <b>$posted</b> On the $date
<br>
</font>");
$file = fopen("news.php", "r");
$read = fread($file, filesize("news.php"));
fclose($file);
$blah = fopen("news.php", "w");
//Leave alone look and learn, only edit if you know
php
$news=stripslashes($news);
fwrite($blah, "$news $read");
fclose ($blah);
print "<meta http-equiv=\"refresh\"
content=\"1;http://www.xtasygaming.com/\">";
//edit path to where the news.php file falls
?>
|
Make a new file called news.php
To make the news appear on your page just use php incldue by
inserting the following code anywhere on anypage.
CODE |
<? include "news.php";?>
|
I also suggest putting a login over the add page so people
cant add news your site without logging in first. If your not
sure how to make a login, I have created a User Authentication
Tutorial also available in the php category.
NOTE: Make sure all files are chmodded to 777.
Tutorial By Xtasy
|
|