FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


dinamic pages





bresti
hello,
how i can made a dinamic page with php

like that :
www.name.com/?contact

with 2 languages en and fr

www.name.com/?contact&fr or something like that

Thanks Bresti
AftershockVibe
It's quite simple actually. Basically, you just pass a variable through the URL which your PHP page then examines and determines what to display based on its value.

If you look at the top of these forums in fact, you get a very good example of this kind of behaviour. For example, writing this post I'm at the URL http://www.frihost.com/forums/posting.php?mode=reply&t=78315

Now, obviously there is only posting.php page and not one created for every post! Now, after the page name you'll see that there is a ? which separates the page URL from the variables passed to it. It has two variables - "mode" (which is what I'm doing to the post - replying) and "t" (which is the topic number I'm replying to).

If you wanted to read these variables from PHP you'd do the following:
Code:
$pageMode = $_GET['mode'];    // (variable will be equal to "reply")
$topicID = $_GET['t'];    // (variable will be equal to 78315)


Hopefully that should give you enough of a start. Laughing
bresti
is so complicated way :


i want to know the way with case and break
sonam
You can do in this way:
Code:
<?php
// get informations from url
$lang = @$_GET['lang']; // @ supress errors if is lang definition empty
switch($lang) {
        case "en": include("en.php"); break;
        case "fr": include("fr.php"); break;
        default: include("en.php");
}
?>


Default will include english page what means if you didn't define language in URL.
For changing language you can use this links. Just change yoursite.com and index page in right page.

English language:
Code:
<?php
echo "<a href = www.yoursite.com/index.php?lang=en> English</a>" ;
?>


French language:
Code:
<?php
echo "<a href = www.yoursite.com/index.php?lang=fr> French</a>" ;
?>


Sonam
Related topics
Brett Tabke's website tutorial
Custom error pages using .htaccess
JSP
How to get your dynamic PHP website crawled better by se ?
Create Web pages without knowing HTML.
my site pages are unavailable!! and cant get to cpanel!
Best Designed Websites?
how can i have 2 sets of error pages
cant access to pages and controlpanel
Editing static HTML pages and CSS in PHP
I have this questions
problems for indexing php pages in google.
Something to say that can make my pages look better ?
Custom Erro pages?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.