Creating a News System with PHP - Part 1
(Page 1 of 4 )
This is part one in a three part series on creating a news system with PHP. This first installment will teach you how to create a very simple news system using only a file as storage.
So, you want to display news on your site? Think it'd be pretty cool to have a page where you can enter something each day and then the whole world gets to see it? Well, I'm here to tell you how in this first installment of "Creating a News System".
First installment? That's right. This first tutorial is going to cover just the very basics - a news system that reads and writes to a text file and that's about it. In the second installment, we will move over to a database. And then in the third installment, we will incorporate features such as commenting and user authentication.
Ok, let's get started. So, what do we need to do first? Well, obviously we can't display any news unless we have news to display. So, let's first build our interface to accept new news. For this, we will use a simple HTML form. We need inputs for a name and the news. We also need an input for a password. In this first installment, we are only going to secure our page with a simple password. In the third part of this tutorial we will add multiple users authenticated from a database. Ok, so the code for our input form should look something like this:
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry"> Your name:<BR> <INPUT TYPE="text" SIZE="30" NAME="name"><BR> The News:<BR> <TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR> News Password:<BR> <INPUT TYPE="password" SIZE="30" NAME="password"><BR> <INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR> </FORM> |
Next: Validating the Form >>
More Miscellaneous Articles
More By Matt Wade