PHP - Select Language Script
Similar TutorialsI wrote this html form: Code: [Select] <form action=filterwords.php method=post ENCTYPE="multipart/form-data" target="iFramestatus"> <input type=hidden name=action value=modified> <input type=hidden name=login value="%%login%%"> <input type=hidden name=ID value="%%ID%%"> <textarea cols=28 rows=4 name=Unused10>%%Unused10%%</textarea> <input type=submit name=submit value=" Update "> </form> Most of this form is filled out by my members area cgi script. I am trying to use filterwords.php to remove curse words from the textarea field "unused10" and then resubmit the data to my members area cgi script "pm.cgi" Here is my php script. <?php $action = $_REQUEST['action'] ; $login = $_REQUEST['login'] ; $ID = $_REQUEST['ID'] ; $text = $_REQUEST['Unused10'] ; $submit = $_REQUEST['submit'] ; function filterBadWords($str){ // words to filter $badwords=array( "[badword1]", "[badword2]"); // replace filtered words with random spaces $replacements=array( "[ ]", "[ ]", "[ ]" ); for($i=0;$i < sizeof($badwords);$i++){ srand((double)microtime()*1000000); $rand_key = (rand()%sizeof($replacements)); $str=eregi_replace($badwords[$i], $replacements[$rand_key], $str); } return $str; } $text = filterBadWords($text); ?> How do i send the modified data to pm.cgi? Did i use the filter script correctly? Thanks for the help Hello everyone For a multilingual website we have to be able to open 1 page in 4 different languages. For example, product 'A' is in Dutch, English, French and German. How can I open the right language file? At the moment I use Code: [Select] http://www.zinncosmetics.nl/shop/product_info.php?products_id=36?language=de but it doesn't work. It allways opens the default Dutch pages. What do I do wrong? I don't have very much php experience (newbie) so please don't make it too difficult for me. Thanks for all help! hello all,
I want to create a script similar to the following two sites:
zopium
livechatinc
i am confused where to start , i want to know what framework will be best for creating such a script i can learn any frameworks and can start working on it ,i have got 2 months to coomplet the project also i want to know what kind of resources i will be required to make a complete set up,
I know i am new to this forum so if i have posted in worng section then please point me to the right section so that i can move the post there or moderators feel free to move this post
i want to know each and every espects that will be required and i should take care of while creating this project
hoping to hear soon from you guys
thanks
Hi All, The Problem: I'm trying to learn how to take records from the NAME row of one table (i.e. Tom, Jim, Chris, Mike) and put them into a SELECT (drop down menu) box, then select a name and save it to a DIFFERENT table where the row is also called NAME, and THEN have that selection I just saved show in the SELECT box as SELECTED when the page refreshes. I have found a hundred websites showing how to bind a SELECT box to a table and put them into a SELECT box via $key => $val and even how to save it to ANOTHER textbox on the page, which is a lot easier, but never a step further as described in the first paragraph above. Seems unbelievable to me since it's so common. Maybe I'm just not using the proper search terms/keywords. Here's an example: Let's say you wanted to notify 3 people of your birthday. So, on the notification page, you would enter three names of people you would want notified all in separate input textboxes with [keys]. So, you enter John, Chris, and Tom into three text boxes and save the page. Done. Now, on another page, I have -- say .... five select boxes. For arguments sake, let's just say I click on all of them one at a time. In each of them, I would only see three names (John, Chris, and Tom). Now, in the first SELECT box I click on John. In the second select box I click on Chris, and on the third I click on Tom. Then save the form. I would like to see John, Chris, and Tom in the first three boxes after refreshing and I would like to see SELECT A NAME on the last two Select boxes that we never did anything with. Remember, there are NO default names in the first table with row called NAMES. They are populated by the user and saved to the row. I'm attaching an image of what the page looks like that I want to see the names and be able to select them. Does anyone have a link to a site that shows how to do this... or maybe have something very basic that would show me the process? Or, if not too difficult, maybe you could show me? Thanks in advance for any help! Attached Files Untitled.jpg 24.97KB 0 downloads i created a insert php code which successfully submit to database but i was lost at some point because what i really wanted was a php code that will print on the next page after submission to db At the minute i am using variables in my tpl files in place of plain text so users can change the language the page is shown in. eg. the tpl file would include: $lang->hello; and the replacement would be $lang['hello'] = 'hello'; the php file would include the language class which replaces the variable in the language file with the array value in the relevant language file. but what happens when i have a phrase with a needed variable in the middle? $lang['msgs'] = 'you have '.$msgs.' messages'; i cant have 'you have' and 'messages' as seperate lang variables as phrases are constructed differently in other languages? so how do i accomplish this? hopefully i habe explained this ok. Hello, I am currently making a small website that requires two languages. This is the class I made: Code: [Select] <?php class languages { public function __construct() { if(!isset($_SESSION['language'])) { $_SESSION['language'] = 'nl'; } $lang = isset($_GET['lang']) ? $_GET['lang'] : ""; $languages = array('en', 'nl'); if(in_array($lang, $languages)) { $_SESSION['language'] = $lang; } } } $languages = new languages; $language = $_SESSION['language']; ?> Now as soon I use index.php?lang=en, the website will display it self in English but, as soon I remove the &lang=en from the URI, the language gets not stored in the session and it displays nl agian. Can somebody help me? Thank you! Hi, I am trying to append a language session like this: Code: [Select] $ATC_itemWeight = floatval("".$row_productos_RS['capacidad_'.$_SESSION['session_idioma'].'']; but I get this error Code: [Select] Parse error: syntax error, unexpected ';' in /usr/home/mysite.com/web/productos_esp.php on line 121 what am I doing wrong? Thanks I have textfield for signature in my form, I m checking if the signature was sent ( if(!empty($_POST['signature'])) and if it's not empty I m putting it into the db. The problem is that, I have noticed a greek user has entered something in greek letters, and function could not deal with it and saved it as it is.( DB field supports greek charset ) I just want to allow english and german chars with special chars ( ",',< etc. ) , no other charset like greek. How can I do that? any function for this purpose ? I got site wirch I like tu turn to multilanguage. Code: [Select] <?=$home_jezik?>This is my variable for language code. So I wonna add it to Code: [Select] <?php echo $redak['novost_naslov_hr']; ?>so that "hr" change to "en" or any other language. I try with this but nothing happens Code: [Select] <?php echo $redak['novost_naslov_.$home_jezik']; ?> what's the best way to have a website in 2 languages? I already have the website duplicated in the 2nd language but I'm thinking on the best way to do the language change. should I just append variables to the URL when clicking on the flag icon on each page to change to the 2nd language? any other ideas?? are all languages possible to be inserted into database and be retrieved directly?? eg: write down the japanese words in the textbox and INSERT those into table and retrieve it using mysql_fetch_array() Is that as simple as that, or i have to modify certain script...for certain language? thanks Hi again PHP Freaks.
So I would like to code something similar to the buy menu of Counter-strike: Global offensive in-game module, just in a browser and for a project of mine. I've made the design in photoshop to illustrate better.
I just don't know what I should look into to make this kind of menu, I would love if someone could explain me what languages that this would require. (I'm guessing HTML, CSS and jQuery but I am not sure) more specific help like which particular codes would be much appreciated.
Here is a picture of what I would like to create. (Also attached)
http://i1227.photobu...zps4195288a.png
Attached Files
CSGOKeyz.png 149.81KB
0 downloads This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321347.0 I came across usage of ^= in one the password hashing codes and am trying to find what this operator means in PHP. Hi! I want to have a first page on my website where you as visitor can choose the preferred language. No login at all. I want to save this choice in a cookie or something. The easiest way So next time he/she visits, the language choice is already made for he/she. Any good suggestions for a php code that works? hello, would anyone could point me in the right direction. ?? i have 2 language buttons along the top on my web site. Code: [Select] <div class="flags"> <ul> <li><a href="#"><img src="templates/template1/images/flags/France.png" alt="France"/></a></li> <li><a href="#" class="current"><img src="templates/template1/images/flags/United Kingdom(Great Britain).png" alt="United kingdom" /></a></li> </ul> </div><!-- #flats --> how do i make it so that if i click on one it will change the sites language. ??? i have it all set up in the db so that there is a default language and if i change the default language the language changes but what code do i need to use to make my buttons changes the language? could anyone point me to some jscript or ajax or something please... many thanks rick According to woorank.com my page shows the following. Language Declared: Missing Detected: en I have used Code: [Select] header('content-type: text/html; charset=utf-8'); but do not know how I declare the language. also how do i specify Language/character encoding how is this done ? Hello, I will tell you whant I want to do first and what I've done so far and hopefuly someone will be able to help. What I hope for is to have one unique index.php that will work everywhere. I don't mind if I have to modify each and add path where it is located since this won't happen often. It needs to take car of preferred language and if someone land in a directory, I want it to load the index.php there. I also look to not expose hidden URL in the browser URL box. See *note 1 below. My directory structure is as follow: /index.php /about/index.php /blahblah/index.php The current index.php I'm trying to build looks like this: <?php if (preg_match('/^www.(.+)$/i', $_SERVER['HTTP_HOST'], $matches)) { header("Status: 301 Move permanently", false, 301); header('Location: http://'.$matches[1].$_SERVER['REQUEST_URI']); exit; } session_start(); $Lang = $_SESSION['lang']; if (!isset($Lang)) { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $Lang = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); $Lang = strtolower(substr(chop($Lang[0]),0,2)); if ($Lang !== 'fr' && $Lang !== 'en') { $Lang = "en"; } } else { $Lang = "en"; } $_SESSION['lang'] = $Lang; } include $_SERVER["DOCUMENT_ROOT"] . ("/index_" . $_SESSION['lang'] . ".php"); ?> First I remove "www." in the address when applies. Not a must but I like that. Then I check if Language is already set, if not I detect and set it for next pages. I finally load the proper page according to language with an "include" so index_en.php remain secret (sort of). *note 1: all my index_xx.php pages in every directory have this: Code: [Select] <script language="javascript" type="text/javascript"> if (self == top) top.location.href="directory/index.php"; </script> When in the root, it seems to work and I get the proper page but if I place this in /about/ then when I tried to load /about/index.php it doesn't work. I think the include on the last line could be the problem. I'm either close or far from it, I don't know. Thank you. When you select language I just got an error message Got an error message that says: This problem can sometimes occur if you are disabled or refused to take accept cookies. I have accepted cookies. My code is: language.php <?php if(!isset($_COOKIE['language'])) { if(!isset($_GET['lang'])) { ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>123</title> <style type="text/css"> <!-- body { background-image: url(images/background.jpg); } .style1 { color: #FFFFFF; font-weight: bold; } --> </style></head> <body> <p><br> <br> <br> <br> <br> </p> <div align="center" style="margin-top:400px;"> <table width="200" border="0"> <tr> <td width="114"><div align="left"><a href="language.php?lang=swe"><img src="http://www.clickbuxer.com/images/swe.jpg" border="0" alt="swedish" /></a></div></td> <td width="1" rowspan="2"> </td> <td rowspan="2"><div align="left"></div></td> <td><a href="language.php?lang=usa"><img src="http://www.clickbuxer.com/images/usa.jpg" border="0" alt="usa" /></a></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><div align="center" class="style1">SWE</div></td> <td> </td> <td width="0"><div align="center"></div></td> <td width="110"><div align="center" class="style1">USA</div></td> </tr> </table> </div> <p align="center"> </p> </body> </html> <?php } else { //Add cookie code $language = $_GET['lang']; setcookie("language", $language, time()+3600);//set to expire in 1 hour, 3600=seconds switch($language) { case usa: $redirect = "http://www.clickbuxer.com"; break; case swe: $redirect = "http://www.clickbuxer.com/sv/index.php"; break; default: $redirect = "http://www.clickbuxer.com"; } header("Location: $redirect"); } } else { //If cookie is already set $language = $_COOKIE['language']; switch($language) { case usa: $redirect = "http://www.clickbuxer.com"; break; case swe: $redirect = "http://www.clickbuxer.com/sv/index.php"; break; default: $redirect = "http://www.clickbuxer.com"; } header("Location: $redirect"); } ?> index.php <?php if(!isset($_COOKIE['language'])) { header("Location: http://www.clickbuxer.com/language.php"); } else { $language = $_COOKIE['language']; switch($language) { case usa: $redirect = "http://www.clickbuxer.com"; break; case swe: $redirect = "http://www.clickbuxer.com/sv/index.php"; break; default: $redirect = "http://www.clickbuxer.com"; } header("Location: $redirect"); } ?> |