Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

$_GET[] after a #fragment ?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

$_GET[] after a #fragment ?

Postby kezdotphp » Tue Feb 18, 2014 1:24 pm

Hi, I need help getting this thing to work, I'm not sure how to $_GET[] data after a fragment in the URL. I've seen it used on websites before for example:

example.com/#home?q=test

A working example is: http://craftland.org/#map&p=aether

they also use fragments to decide which page the user is on
here is the code that I'm using to work the #home:

http://pastebin.com/vAHppEyr

Any help would be great!
Thanks, Kez
kezdotphp
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Feb 18, 2014 1:01 pm

Re: $_GET[] after a #fragment ?

Postby paintitblack » Tue Feb 18, 2014 11:32 pm

In its simplest form, this is what you need:

Code: Select all
$q = $HTTP_GET_VARS['q'] ;
paintitblack
New php-forum User
New php-forum User
 
Posts: 8
Joined: Mon Feb 17, 2014 8:53 pm

Re: $_GET[] after a #fragment ?

Postby kezdotphp » Wed Feb 19, 2014 3:11 am

Didn't work.

Not sure what I'm doing wrong
kezdotphp
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Feb 18, 2014 1:01 pm

Re: $_GET[] after a #fragment ?

Postby kezdotphp » Wed Feb 19, 2014 3:24 am

Apparently $HTTP_GET_VARS was deprecated since version 4.1.0?

[ http://www.php.net/manual/en/reserved.variables.get.php ]

Being replaced with $_GET[] which I've already tried!

Any other suggestions?
kezdotphp
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Feb 18, 2014 1:01 pm

Re: $_GET[] after a #fragment ?

Postby paintitblack » Wed Feb 19, 2014 10:25 pm

I've just tested this on one of my shared hosting account (Linux), and it works fine:

Code: Select all
<?php
$param = $_GET['t'];
echo "The parameter value is: " . $param;
?>


I'm running this PHP code as follows:

Code: Select all
http://mydomain.com/phpcode.php?t=test
paintitblack
New php-forum User
New php-forum User
 
Posts: 8
Joined: Mon Feb 17, 2014 8:53 pm

Re: $_GET[] after a #fragment ?

Postby seandisanti » Thu Feb 27, 2014 10:11 am

The suggested solution is the correct one; but make sure you replace 'q' with the variable name being passed in your form. Also make sure that your form is sending data via 'get' and not 'post'. To make use of the suggestion I mean. Post is actually the better choice as it keeps your url a little cleaner, etc
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.