Forum Moderators: coopster

Message Too Old, No Replies

Using PHP include statement with navigation

include statement with navigation

         

jntcomputers

5:25 pm on Aug 12, 2004 (gmt 0)



I want to use the include statement, but I am new and this is not straight forward for me. I have several pages, lets say; addbanner.php, register.php & login.php. What I would like to do is create a template, called bannerads.php, which would look like the rest of my site. At the top I would have a menu that links to the three pages. Can I use an If/then statement in conjunction with the include statement so that all three pages are dynamically pulled into this page? This is probably pretty simple...

commukitty

6:36 pm on Aug 12, 2004 (gmt 0)



Are you looking for something like...

if($x == 1){
include 'addbanner.php';
} elseif($x == 2) {
include 'register.php';
} elseif($x == 3) {
include 'login.php';
}

which would fetch if depending on the value of x (ie, index.php?x=1)?

jntcomputers

7:25 pm on Aug 12, 2004 (gmt 0)



Yeah, but how do you apply the $x == # to the links?

commukitty

7:50 pm on Aug 12, 2004 (gmt 0)



Yours links would be

<a href=index.php?x=1>link here</a>

Just like a normal link.

judson

2:51 am on Aug 13, 2004 (gmt 0)

10+ Year Member



Okay, that worked. Now, to keep everything within the template... when using forms, I changed the form action to reflect the links (i.e. index.php?x=1, and it works, but what about forms that have an action within them?

For example, one form has login.php?action=blahblahblah. How do I incorporate the index.php?x=1? Or is there another way to do this where the form results will show up in my template?

coopster

3:27 am on Aug 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not sure if I understand what you want here. Are you saying you want to pass more than one variable in your query string? For example:
login.php?action=blahblahblah&x=1

judson

4:50 am on Aug 14, 2004 (gmt 0)

10+ Year Member



Yeah, that is correct. I got it working by using index.php?x=3&action=blahblahblah

Thanks