SitePoint Sponsor |
|
User Tag List
Results 51 to 72 of 72
Thread: Url's with php. HELP!
-
Mar 27, 2003, 09:34 #51
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Helge
Content Writing Service - Get custom SEO articles for 10$
-
Mar 27, 2003, 09:43 #52
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok.
index.phpPHP Code:<?php // index.php
error_reporting(E_ALL);
echo '<h1>This is index.php</h1>';
echo '<p>The page variable coming from the url is: ' . $_GET['page'] . '.</p>';
switch ($_GET['page']) {
case 'add':
include ('add.php');
break;
case 'downloads':
include ('downloads.php');
break;
default:
include ('default.php');
break;
}
?>Code:<h1>Yep!! add.php got included</h1>
-
Mar 27, 2003, 09:45 #53
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What about the default page?
Content Writing Service - Get custom SEO articles for 10$
-
Mar 27, 2003, 09:48 #54
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Using your example, here is what I got:
This is index.php
Warning: Undefined variable: _GET in c:\apache\www\test\index.php on line 4
The page variable coming from the url is: .
Warning: Undefined variable: _GET in c:\apache\www\test\index.php on line 6
HelloContent Writing Service - Get custom SEO articles for 10$
-
Mar 27, 2003, 09:55 #55
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The warnings is coming because of the error level that is set on top of index.php. I always develop with that set to highest.
Ok, I've changed something in index.php
index.phpPHP Code:<?php // index.php
error_reporting(E_ALL);
echo '<h1>This is index.php</h1>';
$self = $_SERVER['PHP_SELF'];
echo "<a href=\"$self\">index</a> | <a href=\"$self?page=add\">add</a>| <a href=\"$self?page=wrong\">errorpage</a>";
$_GET['page'] = (empty($_GET['page'])) ? 'default' : $_GET['page'];
echo '<p>The page variable is: ' . $_GET['page'] . '.</p>';
switch ($_GET['page']) {
case 'add':
include ('add.php');
break;
case 'downloads':
include ('downloads.php');
break;
default:
include ('default.php');
break;
}
?>Code:<h1>This is the default.php</h1>
-
Mar 27, 2003, 09:58 #56
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can go see your example on my site for yourself:
http://www.combats.dynu.com/test/index.phpContent Writing Service - Get custom SEO articles for 10$
-
Mar 27, 2003, 10:01 #57
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
AAAAA!!!!! I'm so confused!!! Is your example online?
Content Writing Service - Get custom SEO articles for 10$
-
Mar 27, 2003, 10:08 #58
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Mar 27, 2003, 10:11 #59
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is what my test page is showing:
This is index.php
Warning: Undefined variable: _SERVER in c:\apache\www\test\index.php on line 5
</FONT>index | add| errorpage The page variable is: default.
This is the default.php
How come I am getting the undefined variable, while you are not?Content Writing Service - Get custom SEO articles for 10$
-
Mar 27, 2003, 10:17 #60
- Join Date
- Oct 2001
- Posts
- 2,686
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I did see that.
And why that is happening is beyond my knowledge. I've never installed/administrated a server so I don't know.
I've highlighted the $self variable in my page. As you can see it works there.
I'm sorry. I don't know what to suggest next.
-Helge
-
Mar 27, 2003, 11:15 #61
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Apache server gurus !!! HELP!
Content Writing Service - Get custom SEO articles for 10$
-
Mar 28, 2003, 08:47 #62
- Join Date
- Nov 2001
- Location
- Atlanta, GA, USA
- Posts
- 5,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can you give us a copy and paste of the line with $_SERVER, as well as the line before and the line after?
Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?
-
Mar 28, 2003, 09:26 #63
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is a long thread and I wasn't able to follow it,
but dragonfly is using php version 4.0.6....
(dragonfly it that's not true please correct me,
but I remember I asked that to you sometimes ago and also doing a netcraft to your website still show 4.0.6 )
That's the reason why he can't access _SERVER, _GET stuffs.
I can't remember how to access "get" variables under that php version, but php gurus will help you on that.
:-) pippoLast edited by pippo; Mar 28, 2003 at 09:30.
-
Mar 28, 2003, 11:02 #64
- Join Date
- Nov 2001
- Location
- Atlanta, GA, USA
- Posts
- 5,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks Pippo, that did not even occur to me.
$HTTP_SERVER_VARS is the older array which behaves similarly to $_SERVER, except it is not a superglobal.
http://us2.php.net/manual/en/languag...predefined.phpUsing your unpaid time to add free content to SitePoint Pty Ltd's portfolio?
-
Mar 30, 2003, 06:06 #65
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Deleted post...
Last edited by dragonfly_7456; Mar 30, 2003 at 06:12.
Content Writing Service - Get custom SEO articles for 10$
-
Mar 30, 2003, 06:06 #66
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What do you mean by, it is not "superglobal"?
Content Writing Service - Get custom SEO articles for 10$
-
Mar 30, 2003, 06:12 #67
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey, it works! Haha! Alrighty!
Content Writing Service - Get custom SEO articles for 10$
-
Mar 30, 2003, 06:34 #68
Originally Posted by dragonfly_7456
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
-
Jul 18, 2003, 08:59 #69
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If anyone is still following this thread. LoL. Here is the end result coding that I used, which I put into the part of my coding, where the pages were to be switched.
PHP Code:<?php
$file = ( isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : 'default' );
$file .= ".php";
$check = @include($file);
if (!$check)
{
include('missing.php');
}
else
{}
?>
Also, if you want, you can change 'page' to whatever you want. 'act' , 'pg', 'file'. Whatever you prefer.Content Writing Service - Get custom SEO articles for 10$
-
Jul 19, 2003, 11:35 #70
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey Dragonfly,
what happen if my server is www.example.com ( your server is www.example.net] ) and my server does not parse .php
If I call your script using:
www.example.net/index.php?page=http://www.example.com/bad-guy
then my file
http://www.example.com/bad-guy.php
will be interpreted in your server and that could do serious damages.
Okay, remote-include must be enabled...
BTW,
I'd suggest another approach.
Maybe an example could be:
PHP Code:<?php
$pagesList = array( "default", "pippo", "dragonfly" );
$page = isset( $HTTP_GET_VARS['page'] ) ? strtolower( $HTTP_GET_VARS['page']) : 'default';
if (in_array($page, $pagesList) ) {
include( $page.'.php' );
}
?>.
Andrea
-
Oct 20, 2003, 12:15 #71
- Join Date
- Oct 2003
- Location
- Moscow, Russia
- Posts
- 24
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is dragonfly_7456.
I can't believe I got this to work, but I did it...
PHP Code:<?php
$pagesList = array( "default", "missing", "help" );
$page = isset( $HTTP_GET_VARS['page'] ) ? strtolower( $HTTP_GET_VARS['page']) : 'default';
$check = @include($file);
if (in_array($page, $pagesList) ) {
include( $page.'.php' );
}
elseif (!$check)
{
include('missing.php');
}
?>
2. index.php loads default.php as the default page.
3. If a page exists but is not in the page list, it will show up as "Missing".
4. If a page is missing, and is called through index.php?page= you will get a default "Missing.php" page.
5. Pages that are in the list load correctly under index.php?page=page
Only problem is, what if my site gets to 100 pages. Will that increase page loading time, or will it still work fine?
-
Oct 21, 2003, 07:52 #72
- Join Date
- Dec 2002
- Location
- Moscow, USSR
- Posts
- 1,092
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ah. Got my account back.
So, will that cause loading time problems when there is over 100 pages?Content Writing Service - Get custom SEO articles for 10$
Bookmarks