I suppose I went about this all wrong. I will keep this simple.
First, I always wanted a user to see nothing but query strings throughout my whole website. This may seem stupid but I just like it. It's how I learned to code through various tutorials and the help of someone whom I consider my mentor.
Let's say I have a weblog, and I am writing the code for a page to add a new entry..
Code: Select all
// add a new entry
if ($_POST)
{
// grab the post variables and do the databse stuff
}
else
{
<form action="addweblog.php" method="post">
<input type="text" name="title" />
<input type="text" name="body" />
</form>
}
You have to POST forms to a real page, you can't use querystrings that call includes.
That is how I structure my pages simply because I think that since it is all related, it should all go in the same place, right?
I
do not want people to see those blah.php urls. I hate them. I don't want the page my form is being processed on to be completely obvious to the user.
Now, sure, I could just have a page like this:
Code: Select all
// add a new entry
if ($_POST)
{
// grab the post variables and do the databse stuff
print '
<h4>Add another entry</h4>
<form action="addweblog.php" method="post">
title: <input type="text" name="title" />
body: <input type="text" name="body" />
</form>';
}
else
{
print '
<h4>Add an entry</h4>
<form action="addweblog.php" method="post">
title: <input type="text" name="title" />
body: <input type="text" name="body" />
</form>';
}
I would have to write the same code twice and then they would be able to see the physical address of the page relative to my domain AND I would have to reinclude all the stuff that has the html and css for the page layout.
I used to think, "ugh why not just redirect them". So I did.
After spending alot of time reading, and a bit of time on this forum, I realised that it would be equally stupid IMO.
So. I finally figured out what I think is a good way to do it, yesterday.
Post everything to one page, index.php, have the classes do everything else.
After reading through this thread, I realise that this probably either seems stupid to everyone else, or I am not explaining myself correctly.
If this thread isn't going to be of any use to anyone because of my inability to explain this, then I will simply delete it.
edit: I also just thought that maybe I am just an idiot and I have bad technique. Trying to find out if how I design things is a 'good' way of doing it is part of what I wanted to accomplish with this thread. I like the way I figured out yesterday, it's easy for me. I wrote four 'pages' in the same amount of time it used to take me to write one. Even though making something work best for myself is the point of learning new ways to implement stuff, I still want to know how other people do it, and what the accepted standard is. I'm also starting to think I should just post a .zip with code so everyone can better understand what I mean.