Creating Pages Using Data Collected From A Form -

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
josephman1988
Forum Newbie
Posts: 15
Joined: Mon Apr 21, 2008 8:29 am

Creating Pages Using Data Collected From A Form -

Post by josephman1988 »

Hi,

I want to create a news system.

Admin.php - Has a form that will allow us to create a new news item. The values will be sent to a MySQL DB. Which can then be called within the new page to generate a the same template with different news.
Index.php - Has the News Item Link, which will display the title and link to the new page that is created with the form.

I know how to send data from a form to a database, aswell as how to retrieve and publish the information, but only on an existing page, thats where my problem lies.

Not sure if anyone can understand what I'm trying to say, but I wanna know the 'topics' i should go towards to learn to build such a feature.
Of course, illustrated code will be very welcome =]

Thanks in advanced,
Joe.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Creating Pages Using Data Collected From A Form -

Post by aceconcepts »

I think i understand what you're getting at.

However, I think you would be much better off creating your site in a more simplistic dynamic fashion.

E.g.

Say you have three news categories "Sport" , "politics" and "business".

When someone views the sports page the body colour changes to blue, politics body colour=black and business=green.

What I'm getting at is that you can use your data to cater for different scenarios - you don't need to create new files.

If I've totally missed the point - forgive me :)
josephman1988
Forum Newbie
Posts: 15
Joined: Mon Apr 21, 2008 8:29 am

Re: Creating Pages Using Data Collected From A Form -

Post by josephman1988 »

Hey,

I'l take another shot at explaining. =]
I have a form, the data inputted in each field will be stored in variables.
$title and $content. These will be inserted into the DB.

Say I input 5 different news articles, all of which when submitted will be available through the home page, I thought the best way to view each individual news article when clicked on would be to create a new page for each when submitting the form.

Is there a better way? (like the method your explaining)
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Creating Pages Using Data Collected From A Form -

Post by aceconcepts »

Yeh, I thought if you take this forum for example the thread titla always appears in the same place in the same style.

This thread title is entered by the user when writing their new topic and then displayed in a fixed location.

So with more relevance to your project, what you could do is display each article in a generic format with regard to the title etc.. and simply populate it from the database.

I hope I'm making more sense this time :D
josephman1988
Forum Newbie
Posts: 15
Joined: Mon Apr 21, 2008 8:29 am

Re: Creating Pages Using Data Collected From A Form -

Post by josephman1988 »

Ah I see what your saying.
Dunno how I would start this however, move me in the right direction perhaps?
- My head hurts -

Thanks for your help mate.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Creating Pages Using Data Collected From A Form -

Post by aceconcepts »

I guess you could start out by designing a template for your articles

e.g. take the following two urls: http://news.bbc.co.uk/1/hi/uk_politics/default.stm and http://news.bbc.co.uk/1/hi/health/default.stm

They are two totally different pages in terms of content yet their layout is more or less identical.

So design a template you'd like to use first.

Once you have done this you should then think about creating a relational database.
josephman1988
Forum Newbie
Posts: 15
Joined: Mon Apr 21, 2008 8:29 am

Re: Creating Pages Using Data Collected From A Form -

Post by josephman1988 »

When I navigate to news.php?id=1 to index.php?news=2 the news is completely different due to the id being called.
That's how it works, correct?
What would be the 'proper' command to call? So All the relevant information is called dependin on this value?

A relational DB is best, but, ATM, I wanna work with the basic if that's pos. =]
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Creating Pages Using Data Collected From A Form -

Post by aceconcepts »

Yes, thats correct.

I guess the content should be based on an article id. In a relational database this article id could be related to as many other database tables - meaning you can store as much different data as you wish that is specific to a single article.
Post Reply