GET vs SUBMIT Button to show sections on one index.php page?


Posted on 16th Feb 2014 07:03 pm by admin

Just curious if one of these ways is better (i.e. more efficient) than the other.

I have an index.php page where there is a menu across the top with 5 choices. For example, HOME | MONKEYS | CATS | DOGS | KANGAROOS.

I have ALL the code for those 5 pages on that single index.php file. Now is it better to...

1. Use FORM SUBMIT BUTTONS for each menu option. So I'd have the action of the form be "index.php" and then code like this for the menu...

Code: <input type='submit' name='submit' value='HOME' ><input type='submit' name='submit' value='MONKEYS' >
And then I would have IF statements to see which Submit button was clicked and show the right info accordingly.

OR

2. Use appended URLs and then use GET to see which info should show, as in...

Code: <a href="index.php?page=home">HOME</a>|<a href="index.php?page=monkeys">MONKEYS</a> (etc, etc)
And then have IF statements using GET to check the URL and show the right info accordingly.

I'm not sure one way is better than the other, but just curious if anyone has any thoughts. Like maybe one of these processes in more server intensive than the other??

NOTE: If I use Google Analytics, I guess might help to see appended URLs to know which page got more hits, rather than just seeing info for index.php without knowing if they visited MONKEYS, or CATS or whatever. But please answer the question as if Google Analytics was not relevant.

Thanks

316 Like 33 Dislike
Previous php-forum Next php-forum
Other php-forum

Quick Syntax Question
Hi folks,

I'm getting the following error: "unexpected T_LNUMBER". I'm trying to b

Deleting a record php
Attempting to setup delete a record page. The below code I put together doesn't seem to work.

Checking if variable is 0 as opposed to NULL/Empty...
I'm trying to write some code that will retrieve a user's access level from my database and if it do

form help
this doesn't work. i want the form action to go the location.href of the submit button chosen.. how

Using two $_POST Function / Switch () statements, second does not work.
Hi all. I’m new to php and am having a problem getting $_POST Function / switch () to work. I

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

for loop without same $i digits?
Hi,

Can some guru please advise how can I accomplish this with a simple for loop ?

I

Comparing Values
Hi
I'm reading data from a database and this seems to work OK.

Each system has an associat

PHP login form help (Done Most of It)
Hi i am having a problem, when i try logging in it is always saying "Invalid Login" im not

Email Form Syantax Issue 2
How to make this look FROM:"OUR TEAM" instead of FROM:abc@mail.com

$headers = "

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash