Forum Moderators: coopster
I have been battling with this for a few days now, as I am new to PHP etc.
<snip>
If anyone can help or suggest somewhere to get the appropriate information you would have one very grateful New Zealander!
Thankyou
[edited by: jatar_k at 8:54 am (utc) on Dec. 5, 2002]
[edit reason] no url's please - thanks [/edit]
So if I can get this straight
1) the form and selected country is submitted on default.php
2) the target of the form is home.php
Then the products pages will contain a price depending on which country they selected.
Is this going to be a one off, or after the person selects their country they will see the products page again and again?
If its the latter, then you need a way for PHP to remember what country was submitted with the form.
One way to do it is to start a session
[php.net...]
Something like
session_register("country")
When someone submits the form, you can register what country they had chosen for the rest of their session(usually until they close their browser window)
That way, you can reference what country they had chosen on the first page without too much hassle.
So on home.php, at the top you could have something like.
<?php
session_register("country")
rest of script
?>
The $country variable should be available on every subsequent page the person clicks on.
Thanks again...
If you turn your browser to refuse cookies, the registered session is passed along in the url
you'll get something like this on each subsequent URL
page.htm?PHPSESSID=ccd3f70bb0e58c5258a3c0f16215412a
I'm assuming that since a form has to be filled, all your future pages are not made for search engine spiders, so even if there was a problem with the likes of Google and Sessions [webmasterworld.com], it won't be a problem for you? :)
//added
there is probably a better way to do it but that'll work ;)
just do an if statement
if($varCountry == 'US')
{
do your stuff
}
else
{
do the other stuff
}
maybe if you were calling the product information from a database you could call a country "1" and another "2" or the like and suck data out depending on the number.
i.e. if you dont want to show prices for two, then dont select it from the database.
hey, you could do it like that depending on the url.
ie if the person submits US then they go to domain.com/1.html or if they submit the other country go to 2.html.
Definetely a few ways to skin a cat :), as said there's probably better ways