RE: [PHP] Updating a GET variable

2010-11-17 Thread Tommy Pham
> -Original Message-
> From: Marc Guay [mailto:marc.g...@gmail.com]
> Sent: Wednesday, November 17, 2010 8:59 AM
> To: PHP General
> Subject: Re: [PHP] Updating a GET variable
> 
> > Nathan previously mention what if instead of a language specific
> > request, you have request for multiple languages.
> 
> I get it now, multiple _simultaneous_ languages.
> 
> Cheers,
> Marc
> 

Also FYI, if you do support multiple languages, don't depend on entirely on
$_SERVER["HTTP_ACCEPT_LANGUAGE"].  I know many folks who are fluent in more
than 1 languages but clueless on technology, specifically configuring their
system and browser on how to read & write those languages.  As for myself, I
don't configure the web browser because of privacy issue ;)

Regards,
Tommy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-17 Thread Marc Guay
> Nathan previously mention what if instead of a language specific request,
> you have request for multiple languages.

I get it now, multiple _simultaneous_ languages.

Cheers,
Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Updating a GET variable

2010-11-17 Thread Tommy Pham
> -Original Message-
> From: Marc Guay [mailto:marc.g...@gmail.com]
> Sent: Wednesday, November 17, 2010 6:30 AM
> To: PHP General
> Subject: Re: [PHP] Updating a GET variable
> 
> > A bit late in the thread.  However, IMO, I don't think session is
> > necessary, unless you intend to save it for later use, during that
> > same visit from the user.  If it's just a 1 time request, you can just
> > use (example) $_GET['lang']=en,de,fr,...
> > Then just split up individual languages, process the request of each
> > supported language, and place each relevant localization in its own
> > tab panel, div (non js), etc...
> 
> Hi Tommy,
> 
> I read this at least 5 times and still don't quite get your meaning, but
I'm
> curious enough to ask:  Could you repeat in other words or give a short
> example?
> 
> Marc
> 

Marc,

Nathan previously mention what if instead of a language specific request,
you have request for multiple languages.  I don't know if that's part of you
web app feature/service or not but you don't need session to process that
request unless you need the results for something else.  This example based
upon that you use URL query parameter to permit the users to change/select
the languages.  I don't know how your app is designed but you can process it
via $_POST also.

$languages = $_GET['lang']=en,de,fr;
$langArray = explode(',', $languages);  // you can use another separator
such as - or _

Than you can process for each of the language:

foreach ($langArray as $lang)
process_request_func ($lang); 

results of process_request_func() for language en
results of process_request_func() for language de
results of process_request_func() for language fr

Or if you have jqueryui or something similar, use tabs for each of those
html content where  each language goes in its own tab.  If you need to save
the results for later use, then you'll need the session.

Regards,
Tommy


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-17 Thread Marc Guay
> A bit late in the thread.  However, IMO, I don't think session is necessary,
> unless you intend to save it for later use, during that same visit from the
> user.  If it's just a 1 time request, you can just use (example)
> $_GET['lang']=en,de,fr,...
> Then just split up individual languages, process the request of each
> supported language, and place each relevant localization in its own tab
> panel, div (non js), etc...

Hi Tommy,

I read this at least 5 times and still don't quite get your meaning,
but I'm curious enough to ask:  Could you repeat in other words or
give a short example?

Marc

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Updating a GET variable

2010-11-16 Thread Tommy Pham
> -Original Message-
> From: Nathan Rixham [mailto:nrix...@gmail.com]
> Sent: Thursday, November 11, 2010 8:18 AM
> To: Marc Guay
> Cc: Tamara Temple; PHP General
> Subject: Re: [PHP] Updating a GET variable
> 
> Marc Guay wrote:
> >> So all you need to do, is take a look at
> >> $_SERVER['HTTP_ACCEPT_LANGUAGE'] to get a users language
> preferences.
> >
> > Hi Nathan,
> >
> > Yep, I'm using this var to set the default but I think it's nice to
> > allow the user to override it.  Maybe someone using their computer is
> > more comfortable in a different language?
> 
> So then surely that would be their default language?
> 
> However, there is of course the case where somebody wants to see both
> english and german variations of the "same" page, so probabyl a good use-
> case after all - session to the rescue!
> 

A bit late in the thread.  However, IMO, I don't think session is necessary,
unless you intend to save it for later use, during that same visit from the
user.  If it's just a 1 time request, you can just use (example)
$_GET['lang']=en,de,fr,... 
Then just split up individual languages, process the request of each
supported language, and place each relevant localization in its own tab
panel, div (non js), etc...

Regards,
Tommy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-11 Thread Nathan Rixham

Marc Guay wrote:

So all you need to do, is take a look at $_SERVER['HTTP_ACCEPT_LANGUAGE'] to
get a users language preferences.


Hi Nathan,

Yep, I'm using this var to set the default but I think it's nice to
allow the user to override it.  Maybe someone using their computer is
more comfortable in a different language?


So then surely that would be their default language?

However, there is of course the case where somebody wants to see both 
english and german variations of the "same" page, so probabyl a good 
use-case after all - session to the rescue!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-11 Thread Marc Guay
> So all you need to do, is take a look at $_SERVER['HTTP_ACCEPT_LANGUAGE'] to
> get a users language preferences.

Hi Nathan,

Yep, I'm using this var to set the default but I think it's nice to
allow the user to override it.  Maybe someone using their computer is
more comfortable in a different language?

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-10 Thread Nathan Rixham

Tamara Temple wrote:


On Nov 10, 2010, at 8:58 AM, Marc Guay wrote:


foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
$qs['lang'] = 'en';
echo 'Flip';


Hi Tamara,

Thanks for the tips.  Do you see any advantage of this method over
using a small POST form besides the styling problems I'll run into
trying to make the submit button look like an achor?


The main advantage I see is that you're application doesn't have to 
become bi-modal, with looking for variables on both the query string and 
in the post data, then deciding which to use.


All browsers send the Accept-Language header from the users locale 
settings, like:


  "Accept-Language:en-GB,en-US;q=0.8,en;q=0.6"

So all you need to do, is take a look at 
$_SERVER['HTTP_ACCEPT_LANGUAGE'] to get a users language preferences.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-10 Thread Tamara Temple


On Nov 10, 2010, at 8:58 AM, Marc Guay wrote:


foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
$qs['lang'] = 'en';
echo 'Flip';


Hi Tamara,

Thanks for the tips.  Do you see any advantage of this method over
using a small POST form besides the styling problems I'll run into
trying to make the submit button look like an achor?


The main advantage I see is that you're application doesn't have to  
become bi-modal, with looking for variables on both the query string  
and in the post data, then deciding which to use.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-10 Thread Marc Guay
> foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
> $qs['lang'] = 'en';
> echo 'Flip';

Hi Tamara,

Thanks for the tips.  Do you see any advantage of this method over
using a small POST form besides the styling problems I'll run into
trying to make the submit button look like an achor?

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-10 Thread Marc Guay
>  Session_start();
> $_SESSION['language'] = "en";
> You can set the session variable to the current get or maintain the original
> passed.

I think you may have misunderstood.  The problem is holding onto the
existing GET variables in the URL while manipulating or adding one of
them... and doing it dynamically no matter what the existing
parameters are.

My partciular problem scenario is this:

directions.php?mode=DRIVING&lat=45.514516&long=-73.611056&zip=H4N+2W2&lang=en

I would like the user to be able to switch between two languages via
the $_GET['lang'] var.


As for

> Dear god, why would you butcher php like that?

Your example is just as ugly as mine and in my editor is actually
worse because the SERVER vars aren't highlighted.   Thanks anyways.


Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Fwd: [PHP] Updating a GET variable

2010-11-09 Thread Tamara Temple

Begin forwarded message:


From: Tamara Temple 
Date: November 10, 2010 12:05:32 AM CST
To: PHP General 
Subject: Re: [PHP] Updating a GET variable


On Nov 9, 2010, at 2:47 PM, Marc Guay wrote:

What's wrong with just putting the url parameters in the link that  
you know

you need, one by one?


I have a footer that I include on every page and would like it to
adapt to whatever situation it finds itself in.  Is your suggestion,
to do the following for the existing example:

echo "Flip";



Also, don't just output the values sent to the server, as that's  
an attack waiting to happen.


Are you referring to echoing the SCRIPT_NAME and QUERY STRING values
into the href attribute?


I would add the parameter you want to $_GET ($_GET['lang']='en') and  
use http_build_query on $_GET if you really want to include the  
whole query string in the call:


$_GET['lang']='en';
echo 'Flip"


Woops, just realized a problem with this. If the values in $_GET are  
URL encode, http_build_query will encode them again, so you have to  
decode them first:


foreach($_GET as $k => $v) $qs[$k] = URLDecode($v);
$qs['lang'] = 'en';
echo 'Flip';


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-09 Thread Tamara Temple


On Nov 9, 2010, at 2:47 PM, Marc Guay wrote:

What's wrong with just putting the url parameters in the link that  
you know

you need, one by one?


I have a footer that I include on every page and would like it to
adapt to whatever situation it finds itself in.  Is your suggestion,
to do the following for the existing example:

echo "Flip";



Also, don't just output the values sent to the server, as that's an  
attack waiting to happen.


Are you referring to echoing the SCRIPT_NAME and QUERY STRING values
into the href attribute?


I would add the parameter you want to $_GET ($_GET['lang']='en') and  
use http_build_query on $_GET if you really want to include the whole  
query string in the call:


$_GET['lang']='en';
echo 'Flip";



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Updating a GET variable

2010-11-09 Thread admin
No,
Try this.

?&lang=en'>Flip


Dear god, why would you butcher php like that?

I, like many prefer short code or at least concat the string.
Flip





Richard L. Buskirk

-Original Message-
From: Marc Guay [mailto:marc.g...@gmail.com] 
Sent: Tuesday, November 09, 2010 3:48 PM
To: a...@ashleysheridan.co.uk
Cc: php-general
Subject: Re: [PHP] Updating a GET variable

> What's wrong with just putting the url parameters in the link that you
know
> you need, one by one?

I have a footer that I include on every page and would like it to
adapt to whatever situation it finds itself in.  Is your suggestion,
to do the following for the existing example:

echo "Flip<
/a>";


>  Also, don't just output the values sent to the server, as that's an
attack waiting to happen.

Are you referring to echoing the SCRIPT_NAME and QUERY STRING values
into the href attribute?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-09 Thread Marc Guay
My working solution was to put it in a form with a hidden input with
the correct name and value.






But I'm still wondering what your advice is regarding best practice.

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-09 Thread Marc Guay
> What's wrong with just putting the url parameters in the link that you know
> you need, one by one?

I have a footer that I include on every page and would like it to
adapt to whatever situation it finds itself in.  Is your suggestion,
to do the following for the existing example:

echo "Flip";


>  Also, don't just output the values sent to the server, as that's an attack 
> waiting to happen.

Are you referring to echoing the SCRIPT_NAME and QUERY STRING values
into the href attribute?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Updating a GET variable

2010-11-09 Thread a...@ashleysheridan.co.uk
Don't think about it in those terms and you'll see why it wasn't working.

Http is stateless, so unless you use sessions, it will 'forget' everything from 
page to page.

What's wrong with just putting the url parameters in the link that you know you 
need, one by one? If you have many, build a little function for it to reduce 
code repetition. Also, don't just output the values sent to the server, as 
that's an attack waiting to happen.

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "Marc Guay" 
Date: Tue, Nov 9, 2010 20:12
Subject: [PHP] Updating a GET variable
To: "php-general" 

Hi folks,

I'm sure this is an easy one that's standing right in front of me but
I'm too blind to see.  I have a page with an URL like this:
index.php?name=value&this=that. I have a link on the bottom of the
page which allows the user to switch languages.  I need to hang onto
the existing $name and $this get variables.

I tried

Flip

and it loses all previous GET data.  Then I tried

?&lang=en'>Flip

And it continually appends more &lang=en's to the URL if the user
keeps clicking on it (for whatever reason).

Now I've put it in a form and it works as expected, but the display
value and my under-the-hood value need to be different, so it's a
fail.  What's the best way to update the value of a GET var?

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Updating a GET variable

2010-11-09 Thread Marc Guay
Hi folks,

I'm sure this is an easy one that's standing right in front of me but
I'm too blind to see.  I have a page with an URL like this:
index.php?name=value&this=that. I have a link on the bottom of the
page which allows the user to switch languages.  I need to hang onto
the existing $name and $this get variables.

I tried

Flip

and it loses all previous GET data.  Then I tried

?&lang=en'>Flip

And it continually appends more &lang=en's to the URL if the user
keeps clicking on it (for whatever reason).

Now I've put it in a form and it works as expected, but the display
value and my under-the-hood value need to be different, so it's a
fail.  What's the best way to update the value of a GET var?

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php