some optimization for IPPF forms
[openemr.git] / interface / language / lang_language.php
blob2e155a7075520a04ae2c81896ce665037cab03e4
1 <?php
2 require_once("language.inc.php");
5 if ($_POST['Submit']=='Add'){
6 //validate
7 $pat="^[a-z]{2}\$";
8 if (!check_pattern ($_POST['lang_code'],$pat)) {
9 xl ("Code must be two letter lowercase",'e','','<br>');
10 $err='y';
12 /*
13 $pat="^[a-Z]+\$";
14 if (!check_pattern ($_POST['lang_name'],$pat)) {
15 echo ("Only letters accepted for description<br>");
16 $err='y';
19 $sql="SELECT * FROM lang_languages WHERE lang_code LIKE '%".$_POST['lang_code']."%' or lang_description LIKE '%".$_POST['lang_name']."' limit 1" ;
20 $res=SqlQuery($sql);
21 if ( $res ) {
22 xl ("Data Alike is already in database, please change code and/or description",'e','','<br>');
23 $err='y';
25 if ($err=='y'){
26 $val_lang_code=$_POST['lang_code'];
27 $val_lang_name=$_POST['lang_name'];
28 } else {
29 $sql="INSERT INTO lang_languages SET lang_code='".$_POST['lang_code']."', lang_description='".$_POST['lang_name']."'";
30 SqlStatement ($sql);
31 xl('Language definition added','e','','<br>');
37 <TABLE>
38 <FORM name="lang_form" METHOD=POST ACTION="?m=language">
39 <TR>
40 <TD><?php xl('Language Code','e') ?>:</TD>
41 <TD><INPUT TYPE="text" NAME="lang_code" size="2" maxlength="2" value="<?php echo $val_lang_code; ?>"></TD>
42 </TR>
43 <TR>
44 <TD><?php xl('Language Name','e') ?>:</TD>
45 <TD><INPUT TYPE="text" NAME="lang_name" size="24" value="<?php echo $val_lang_name; ?>"></TD>
46 </TR>
47 <TR>
48 <TD></TD>
49 <TD><INPUT TYPE="submit" name="Submit" value="<?php xl('Add','e'); ?>"></TD>
50 </TR>
51 </FORM>
52 </TABLE>