Posts: 720
Threads: 46
Joined: Oct 2001
Okay, I'm totally lost on the PHP thing. I'm trying to pass variables into my 'index.php' so that I can use a case statement to select which block of code to display in the main view. Currently it's showing all of them:
http://wizardcode.port5.com
Now, I have a switch statement in there that's supposed to display the pages based on the variable $page. How do I give this a value? I tried this (just a shot in the dark...), but it didn't do anything:
http://wizardcode.port5.com/index.php?s=&page=0
Posts: 1,166
Threads: 62
Joined: Apr 2003
your server must not have render_globals on.
At the beginning of your code, put this line:
Code:
parse_str($_SERVER['QUERY_STRING']);
It'll parse the variable values into the proper variables. Cool, huh?
am an asshole. Get used to it.
Posts: 594
Threads: 11
Joined: Oct 2002
You can do this:
Code:
if (!empty($HTTP_POST_VARS['page']) || !empty($HTTP_GET_VARS['page']))
{
$page = (!empty($HTTP_POST_VARS['page'])) ? $HTTP_POST_VARS['page'] : $HTTP_GET_VARS['page'];
}
else
{
$page = '';
}
B 4 EVER
Posts: 720
Threads: 46
Joined: Oct 2001
I don't understand what that does. Sorry I haven't had a chance to try the other code either. I have to upload with FTP and it's a lot more trouble to work on the site than it was on Angelfire. I need a real chunk of time, not just a half-hour here and there.
Posts: 1,166
Threads: 62
Joined: Apr 2003
I hope you're not referring to my code, so blurg.
if (!empty($HTTP_POST_VARS['page']) || !empty($HTTP_GET_VARS['page']))
/*This part above just says if the POST or GET variables are not empty, do this code*/
{
$page = (!empty($HTTP_POST_VARS['page'])) ? $HTTP_POST_VARS['page'] : $HTTP_GET_VARS['page'];
}
/*The code above says if the POST variable has something in it, page equals that, if not, then it equals the GET variable.*/
else
{
$page = ''"; //Nothing, nar.
}
am an asshole. Get used to it.
Posts: 720
Threads: 46
Joined: Oct 2001
Hmm... I still don't understand the difference between POST and GET vars... Couldn't I just put $HTTP_POST_VARS['page'] right into the case statement?
Posts: 1,166
Threads: 62
Joined: Apr 2003
POST variables aren't able to be input through the address bar, GET variables are.
in the url
http://domain.com/index.php?var=8
var is the GET variable. POST are more secure, but GET allows the user to bookmark and such.
am an asshole. Get used to it.