Forum Moderators: coopster

Message Too Old, No Replies

get a varibal value from url?

get a varibal value from url?

         

xbl01234

10:06 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



Hi;
I'd like to ask you how i get a varibal value from url.

the url is "http://mysite.com/country/Category.php?page=1/"

i want to get the page value.

i tried the following, it does not work.

echo $_GET["page"];
echo $_POST["page"];
echo $_REQUEST["page"];

could anyone tell me hoe to get the value of page, please.

mooger35

10:20 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



Your problem is the / at the end.

ex:
http://www.example.com/country/Category.php?page=1

$_GET['page'] will now equal 1.

[edited by: dreamcatcher at 6:35 am (utc) on Nov. 24, 2007]
[edit reason] Use example.com, thanks. [/edit]

xbl01234

11:20 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



my url become to "http://www.example.com/country/Category.php?page=1"

and i tried to print out the value by print_r[$_REQUEST['page']

it still not work.

the following is my work, could you help me to find out why? thanks.

in the .htaccess file, i create a rewrite rule.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=([^&]+)
RewriteRule ^([a-z]+)/Category.php$ /Category.php?[L]

then in the index.php file

<a href="country/Category.php?page=1">the country </a> <br>
<a href="city/Category.php?page=1"> the city </a> <br>

and in the category.php
echo $_GET['page'];
or $_REQUEST['page'];
or $_POST['page'];

but it does not work.

[edited by: dreamcatcher at 6:36 am (utc) on Nov. 24, 2007]
[edit reason] Use example.com, thanks. [/edit]