Ok, So I am using a $_GET function as a main navigation tool. Yes, I am using PHP, I did not come here to get ridiculed, I came here for assistance.
So I have the script something like:
<?php
$page = $_GET['p'];
if ($page == ""){
require 'index.htm';
};
if ($page == "about"){
require 'aboutme.htm';
};
if ($page == "links"){
require 'links.htm';
};
?>
And I have seen this work before, However I am running this off a different server on my own IP address instead of on a host. Basically the error I keep getting is that "p" is not defined. So, simply "page.php" will not load, however "page.php?p" will load. I have never had this happen before. Usually if the $_GET is set to '', then running page.php by itself will just cause the index page to show up instead.
I really don't understand what I did wrong. Please help /prog/.
I really don't understand what I did wrong.
Perhaps it's because you use a screen real estate-saving font.
Name:
Anonymous2010-06-02 2:32
>>3
Alternatively, if you like this syntactic sugar such as: $page = (isset($_GET['p')) ? $_GET['p'] : 'index';
As for the ifs, you could try something like this instead: switch ($page)
{
case 'index':
case 'about':
case 'links':
$page .= '.html';
break;
default:
$page = '404.html';
break;
}
require($page);
etc...
>>16
I believe the OP is running Windows so this is not an issue
Name:
Anonymous2010-06-02 18:40
Just use static pages, please. Ones which will result in useful headers (modified dates, sizes, etc) being returned to clients; not shitty dynamically-generated pages that serve no purpose other than PHP bragging rights. And ones which don't use the shitty ?p=whatever added on to the end of the URL.
Name:
Anonymous2010-06-02 18:44
>>18
Static pages are not as flexible. What if you need to change the header or footer? You'd have to do a copy/paste
>>20
This is not static. PHP has to fetch header.php and footer.php every time the page is requested. It still has all the problems that >>18 pointed out.
Name:
Anonymous2010-06-02 19:13
>>19
Use a program to generate the static pages. Save on bandwidth.
>>21
How could dynamically including a common template to a page that is otherwise "static" (in the sense that it is its own file within the server folder structure and not accessed through a RESTful controller) possibly harm the HTTP headers?
Name:
Anonymous2010-06-02 23:38
>>24
the correct timestamp and file sizes probably aren't being sent.
Name:
Anonymous2010-06-02 23:57
Not to mention that dynamically generating output using CPU-hungry PHP code wastes lots of energy and is bad for the environment.
Name:
Anonymous2010-06-03 0:06
The most effective way to handle this would be store a cached version of each PHP page in a database entry, keyed by p= value. Then each page would first check to see if a cache entry for itself exists, and if so, serve that and exit rather than generating the page again. The cache entries would have to be refreshed whenever you made a change to the page, but considering that reads are much more frequent than updates, that would not be a big hardship.
Name:
Anonymous2010-06-03 7:41
Just use <frame>s
Name:
Anonymous2010-06-03 9:17
>>27
You want to keep entire copies of pages in a database? Why not just p= keys and "source" (raw content) and file (static, generated with >>20) locations? If a source is unmodified, just print a Location: /generated-file.php header, otherwise regenerate it beforehand.
Name:
Anonymous2010-06-03 11:57
Make separate files for index.php, links.php, and aboutme.php.
Write them each independently until you find that there are resources you can share. Put that in a file called Template.php, preferably in a folder out of reach from browser clients, but it doesn't really matter.
Inside Template.php, you might have something like this:
<?php
class Template
{
static function header($title, $stylesheet)
{
?>
>>37
Doesn't make sense. The generation process is likely to be disk-bound: the bottleneck will be the speed at which you can fetch files off disk, concatenate them and write them to the output directory. Choosing Assembly over C will not give you any significant gains there.
>>51
I'm sorry we could not conform strictly to your memetic standards. Perhaps you would be more comfortable on one of 4chan's many friendly and predictable imageboards.