Honesty Rocks! truth rules.

2 Pages Into One how?

HOME      >>       Programming

demonlord

Hello, now this may be a stupid question but i'm very new to php so i need some help. what i'm wanting to do is combine 2 pages in to one. like for example the install.php for invisionpower board it starts with one page and you click continue and it gives you a whole new page but if you look at the url you are still using the install.php file but it has somethinglike "?a=2" at the end. how can i do this. Thanks


sonesay

You can control what gets processed in index.php by taking the tagged get variables at the end of the URL and using it in your code.For example if you have a file called index.php

<?php$do = $_GET['do'];if($do == 'option1'){ // do what ever you need to be done here}else if($do == 'option2'){ // do what ever you need to be done here}?>?>

so now you can make links that go to index.php and add controls to it by adding to the end of the URLi.e index.php?do=dothis


demonlord

never mind i see you edited you post and what you put in had the answer to what i was going to ask.Thanks for posting this


kobra500

Hmm im trying to learn php but its the one language I cant get my head round!


demonlord

yeah i know i've been trying to learn it for about a month now with no progress. it's hard


sonesay

I was in your shoes a few years ago, I ended up buying a book and went through the tutorials in them. It helped but then I was way to busy and never even did any PHP for a year or 2 and then I never progressed. The only advice I can give you is keep doing it. Thats how I improved, You know the old saying hard work really pays off and it does. You may not pick it up in a few days/weeks/months but you will pick it up eventually. And also if your stumped you can always post here.Good luck.


demonlord

after i started this topic i actuly went out and got some books on php and i'm going to sit down and go through them and make a whole lot of notes so hopefuly that will help.and thanks again for the help


jlhaslip

Here is a link to a Tutorial I wrote some time ago. Back when I was just starting out learning some php. I would do things a little differently now, but it might assist you with the task you face.
Any questions, just post them to that thread, please.

http://forums.xisto.com/topic/35271-templating-system-using-php-includes-building-a-dynamic-site-using-includes-and-flat-files/


demonlord

sonesay i have one more question about the scriptwhere do i put the code that i want to show up if $do is Null for example if i name the script act.php where would i put the code that they would see if they went to act.php instead of act.php?z=whatever.Thanks


sonesay

sonesay i have one more question about the script
where do i put the code that i want to show up if $do is Null for example if i name the script act.php where would i put the code that they would see if they went to act.php instead of act.php?z=whatever.

Thanks



{
// do what ever you need to be done here
}
else if($do == 'option2')
{
// do what ever you need to be done here
}
else
{
// the previous 2 checks didn't match do this section of code
}
linenums:0'>if($do == 'option1'){// do what ever you need to be done here}else if($do == 'option2'){// do what ever you need to be done here}else{// the previous 2 checks didn't match do this section of code}
You can add more else if checks if needed but its too hard to cover all possibilities so if none match you can add a final statement of else at the bottom and it will execute if none of the above checks are true.

demonlord

thanks sonesay, one more question does the else have to be the very last one or can i put it at the begining of the script? and thanks again for the help