PHP, ASP, or CGI Question... Please help!

pmark

Senior member
Oct 11, 1999
921
1
81
I think don't understand what you are trying to do. So you are trying to include a header on every page, but the content of this header is linked to the value in a variable?

So if variable is 1 then include this header

elseif variable is 2 then include this header.

Is that what you are trying to do?
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
Not sure what you are trying to do here, I know php btw..


If you are trying to do what I think you are trying to do then you have to have a index page with "case"

In php (not sure if this is all correct, cant remember:))


switch ($var) {
case page1
$page=page1.php;
exit;
case page2
$page=page2.php;
exit;
}


Then you create the html part and put somewhere <?php include($page); ?>
Then you create a link on the page that links to index.php?var=page1 and index.php?var=page2

when you click on each link it puts page2.php or page1.php where you set the include function.
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Well here's what I have in my head :p.


The cgi file was going to be called displayme.cgi or something...

Inside that file I'm going to include the html skeleton of my page.

Like for example the html file will read:

<html>
<head>
<title>$PageTitle</title>
</head>

<body bgcolor=&quot;$BGColor&quot; Text=&quot;$TextColor&quot;>
<p>$Paragraph_1</p>
<p>$Paragraph_2</p>
</body>

</html>

What I could do is hard link a file using this command to input the data:

eval {
($0 =~ m,(.*)/[^/]+,) &amp;&amp; unshift (@INC, &quot;$1&quot;); # Get the script location: UNIX / or Windows /
($0 =~ m,(.*)\\[^\\]+,) &amp;&amp; unshift (@INC, &quot;$1&quot;); # Get the script location: Windows \

require &quot;whatever.file&quot;;
};


And that file will have commands like:

$PageTitle=&quot;Welcome to my webpage!&quot;;
$BGColor=&quot;#FFFFFF&quot;;
$TextColor=&quot;#000000&quot;;
$Paragraph_1=&quot;Whatever...&quot;;
$Paragraph_2=&quot;Whatever...&quot;;


What will then happen is the data from the whatever.file will be plugged into the displayme.cgi file and display the html on the browser... Follow so far?


No what I want to do is not use a hard coded file in the &quot;require&quot; section... I want to be able to have the file required be determined by the command line, like so:

http://www.yoursite.com/displayme.cgi?use=whatever.file


Something like that... This way I can use any file that has those parameters in it.

Let me know if and how this can be done in CGI, PHP or ASP. :)

Thanks!




 

BowDown

Banned
Jun 2, 2000
2,197
0
0


<< Then you create the html part and put somewhere <?php include($page); ?> >>



I think you're on the right track... :) I have made my description a little bit clearer :).
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
This is easy I think, not sure but try this

instead of ---- require &quot;whatever.file&quot;;
do ---- require &quot;$file&quot;;

and the links should then be link.html?file=whatever file you want to display
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
The only problem with using a Case Switch is it's still hard coded... You're saying that the variable thats going to be used refers to a certian page. Is that a way to just have the Script read in the filename typed and just include that into the script?
 

BowDown

Banned
Jun 2, 2000
2,197
0
0


<< and the links should then be link.html?file=whatever file you want to display >>



:(

It works fine when it's hardcoded to include &quot;text.ini&quot;, but when I use:

temp.cgi?file=text.ini

It doesn't work...
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
What if you just put

$file=&quot;text.ini&quot;
reqire &quot;$file&quot;

does that work?
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Yup... of course it works.

If you define $file as being &quot;text.ini&quot;, then it's just like including &quot;text.ini&quot;.
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
How would you do this in PHP? I'm willing to change... it doesn't have to be CGI.

I don't care if I have to use a table of values:

ex:

0001 = review001.fst
0002 = review002.fst
ect...


Kind of like Fusetalk is setup (check the message bar on top).
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
Here is an example from a page I did in php.. or more like just a smaller version of it
(I used dots instead of space

<?php
. switch($cat):
... case page1:
..... $main = &quot;page1.php&quot;;
..... break;
... case page2:
..... $main = &quot;page2.php&quot;;
..... break;
... default:
..... $main = &quot;default.php&quot;;
. endswitch;
?>

<a href=index.php?cat=page1>Page1</a><br>
<a href=index.php?cat=page2>Page2</a><br>
<table>
<tr>
<td>
What you want
</td>
<td>
<?php include($main); ?>
</td>

And thats it... I find php much easier than cgi or asp.. go to www.webmokey.com and find the php section there and read the php/mysql tutorial.
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
That sounds more like what I'm trying to do :). Now can PHP import information from another file and display it in given fields of one php page?

I read the Webmonkey thing, didn't seem like what I wanted to do... They were using headers inside every file to define what the content was in the page. I read through the CF information... Now that's nice, and more along the lines of what I want, but it's like $1000 for a license. :(
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
the webmonkey page is just a tutorial so you can see how php works.

still of all the server side languages I´v seen php is by far the best.
 

BowDown

Banned
Jun 2, 2000
2,197
0
0
Hmm... Anyone know of a good CGI site? I have read the info at Webmonkey and gained pretty much nothing that I didn't already figure out... :(


Thanks!
 

ASK THE COMMUNITY