MOON
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4
System: Linux vps.panamaemb.org.sg 3.10.0-1160.80.1.vz7.191.4 #1 SMP Thu Dec 15 20:31:06 MSK 2022 x86_64
User: panama (500)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: /home/panama/public_html_old/appform.php
<?php require_once ("./include/ewconfig.php") ?>
<?php require_once ("./include/db.php") ?>
<? 
	include("include/config.php"); 	
	$db_sel = new database();
	$pageid=10;
	$db_sel->where("pageid=".$pageid);
	$db_sel->selectstmt("cmspagemaster");
	$pagetitle = $db_sel->f_pagetitle;
	$pagemeta = $db_sel->f_pagemeta;
	$pagemetadesc = $db_sel->f_pagemetadesc;
	//$str_len=strlen($db_sel->f_pagedesc);
	//if($str_len>1100) 
	//$description = substr($db_sel->f_pagedesc,0,1100)."...";
	//else 
	$description = $db_sel->f_pagedesc;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="<?=$pagemetadesc?>" />
<meta name="keywords" content="<?=$pagemeta?>"/>
<title><?=SITE_TITLE."- Services - ".$pagetitle?></title>
<!-- Stylesheets -->
<link rel="stylesheet" type="text/css" href="styles.css"/>
<!-- Javascript -->
<!--[if IE 6]><script src="js/ie6.js"></script><![endif]--> 
<link rel="stylesheet" href="css/dropdownmenu.css" type="text/css" />
<script type="text/javascript" src="js/dropdownmenu.js"></script>
<? include('includescript.php')?>
</head>

<body>
<? include("header.php") ?>
<div id="contentwrapper">
  <div class="contentcontainer">
    <div class="maincontainer">
      <div class="servicesbannerwrapper"><img src="images/banner_services.jpg" width="958" height="178" alt=""/></div>
    </div>
    <div class="maincontainer">
      <div class="visaformwrapper" style="width: 1116px; height: 1723px">
        <div class="title">
          <div class="breadcrumbs">
            <ul>
              <li class="first"><span class="titleicons"><img src="images/icon_services.png" width="40" height="42" alt=""/></span>&nbsp;Services</li>
              <li>
                <?=$pagetitle?>
              </li>
            </ul>
          </div>
        </div>
        <div > <font size="3">Please Fill up the application form.</font>&nbsp;
            <form enctype="multipart/form-data" name="appform" method="POST" action="appform.php" onsubmit="return checkInput(this);">
            <script type="text/javascript" language="javascript">
					function checkInput(appform)
					{
						if(appform.txtFirstName.value=="" && appform.txtMiddleName.value=="" && appform.txtSurname.value=="")
						{
							alert("Name Can not be all empty!");
							appform.txtFirstName.focus();
							return false;
						}
						if(appform.txtPassportNo.value=="")
						{
							alert("Passport No Can not be empty!");
							appform.txtPassportNo.focus();
							return false;
						}
						if(appform.txtNationality.value=="")
						{
							alert("Nationality Can not be empty!");
							appform.txtNationality.focus();
							return false;
						}
						if(appform.txtCountry.value=="")
						{
							alert("Country of Birth Can not be empty!");
							appform.txtCountry.focus();
							return false;
						}
						if(appform.txtCity.value=="")
						{
							alert("City Can not be empty!");
							appform.txtCity.focus();
							return false;
						}
						if(appform.txtDay.value=="")
						{
							alert("Day of Birth Can not be empty!");
							appform.txtDay.focus();
							return false;
						}
						if(appform.txtMonth.value=="")
						{
							alert("Month of Birth Can not be empty!");
							appform.txtMonth.focus();
							return false;
						}
						if(appform.txtYear.value=="")
						{
							alert("Year of Birth Can not be empty!");
							appform.txtYear.focus();
							return false;
						}
						
						if(appform.txtEmployerAddress.value=="")
						{
							alert("Address Can not be empty!");
							appform.txtEmployerAddress.focus();
							return false;
						}
						return true;
					}
					</script>
              <table border="0" width="775" id="table1" height="auto">
                <tr>
                  <td align="left" height="36" valign="top" colspan="2"><p align="left"><font color="#000000" size="2"><b>NOMBRE</b>-Name(First):</font><font face="Arial, Helvetica, sans-serif">
                  <?php
				  	if (@$_GET["userid"] <> "")
					{
						$userid=@$_GET["userid"];
						$action=@$_GET["action"];
						$appid=@$_GET["appid"];
						$viewuser=@$_GET["viewuser"];
						$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
						MySQL_query("SET NAMES 'utf8'");
						/*Action 1.New 2.Edit 3.Delete 4.View*/
					if($action=="1")
					{
						//echo "<script language=javascript>alert('New App!!!');</script>";
						$showfile1=".\\visattach\\nofile.jpg";
						$filelink1="";
						$showfile2=".\\visattach\\nofile.jpg";
						$filelink2="";
						$showfile3=".\\visattach\\nofile.jpg";
						$filelink3="";
					}
				  	if($action=="2" or $action=="4")/*Edit App or View App*/
					{
						if($userid=="0")
						{ 
							$StrSel="Select * from visa_form Where userid=".$viewuser." and appid='".$appid."'";
						}
						else
						{
							$StrSel="Select * from visa_form Where userid=".$userid." and appid='".$appid."'";
						}
						$query = phpmkr_query($StrSel, $conn) or die("<font color='#FF0000'>ERROR: Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql."</font>");
						$row = @phpmkr_fetch_array($query);
						$query = phpmkr_query($StrSel, $conn) or die("<font color='#FF0000'>ERROR: Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $sSql."</font>");
						if (phpmkr_num_rows($query) > 0)
						{
							//Edit App Load App Information
							$imgfolder=".\\visattach\\";
							$pdfico="pdfile.png";
							$firstname=$row["firstname"];
							$middlename=$row["middlename"];
							$surname=$row["surname"];
							$passport=$row["passport"];
							$nationality=$row["nationality"];
							$country=$row["country"];
							$city=$row["city"];
							$day=$row["daybirth"];
							$month=$row["monthbirth"];
							$year=$row["yearbirth"];
							$address=$row["employeraddress"];
							$fun1=$row["function1"];
							$fun2=$row["function2"];
							$fun3=$row["function3"];
							$fun4=$row["function4"];
							$fun5=$row["function5"];
							$level1=$row["level1"];
							$level2=$row["level2"];
							$level3=$row["level3"];
							$level4=$row["level4"];
							$level5=$row["level5"];
							$funclimit1=$row["funclimit1"];
							$funclimit2=$row["funclimit2"];
							$funclimit3=$row["funclimit3"];
							$funclimit4=$row["funclimit4"];
							$funclimit5=$row["funclimit5"];
							$cargo1=$row["cargo1"];
							$cargo2=$row["cargo2"];
							$cargo3=$row["cargo3"];
							$cargo4=$row["cargo4"];
							$cargolimit1=$row["cargolimit1"];
							$cargolimit2=$row["cargolimit2"];
							$cargolimit3=$row["cargolimit3"];
							$cargolimit4=$row["cargolimit4"];
							$indicatepos=$row["indipos"];
							
							$cap1=$row["cap1"];
							$cap2=$row["cap2"];
							$cap3=$row["cap3"];
							$cap4=$row["cap4"];
							$cap5=$row["cap5"];
							$cap6=$row["cap6"];
							
							$specialtrain1=$row["specialtrain1"];
							$specialtrain2=$row["specialtrain2"];
							$specialtrain3=$row["specialtrain3"];
							$specialtrain4=$row["specialtrain4"];
							$specialtrain5=$row["specialtrain5"];
							$specialtrain6=$row["specialtrain6"];
							$specialtrain7=$row["specialtrain7"];
							$specialtrain8=$row["specialtrain8"];
							
							$file1=$row["file1"];
							$file2=$row["file2"];
							$file3=$row["file3"];
							if($file1=="")
							{
								$showfile1=".\\visattach\nofile.jpg";
								$filelink1="";
							}
							else
							{
								if(substr(strrchr($file1,"."),1)=="pdf")
								{
									$showfile1=".\\visattach\pdfile.png";
								}
								else
								{
									$showfile1=$imgfolder.$file1;
								}
								$filelink1=$imgfolder.$file1;
							}
							if($file2=="")
							{
								$showfile2=".\\visattach\nofile.jpg";
								$filelink2="";
							}
							else
							{								
								if(substr(strrchr($file2,"."),1)=="pdf")
								{
									$showfile2=".\\visattach\pdfile.png";
								}
								else
								{
									$showfile2=$imgfolder.$file2;
								}
								$filelink2=$imgfolder.$file2;
							}
							if($file3=="")
							{
								$showfile3=".\\visattach\\nofile.jpg";
								$filelink3="";
							}
							else
							{
								if(substr(strrchr($file3,"."),1)=="pdf")
								{
									$showfile3=".\\visattach\pdfile.png";
								}
								else
								{
									$showfile3=$imgfolder.$file3;
								}
								$filelink3=$imgfolder.$file3;
							}
						}
						else
						{
							
						}
					} 
					}
                  ?>
                      <input type="text" name="txtFirstName" value="<?php echo $firstname; ?>" <?php if($action=="4") echo "disabled"; ?> size="15">
                  </font></p></td>
                  <td height="36" colspan="3" align="left" valign="top"><p align="left" style="text-align: left"><b><font size="2">MEDIO</font></b><font size="2">-Middle Name:</font><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtMiddleName" value="<?php echo $middlename ?>" <?php if($action=="4") echo "disabled" ?> size="15">
                  </font></p></td>
                  <td height="36" colspan="3" align="left" valign="top"><p align="left"><b><font size="2"> APELLIDO</font></b><font size="2">-Surname</font><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtSurname" value="<?php echo $surname ?>" <?php if($action=="4") echo "disabled" ?> size="15" />
                  </font></p></td>
                </tr>
                <tr>
                  <td align="center" colspan="8">
					<p align="left" style="text-align: left; margin-bottom:0em"><b> <font size="2">No. DE PASAPORTE</font></b><font size="2">- 
                    Passport No.</font><font face="Arial, Helvetica, sans-serif">
                                    <input type="text" name="txtPassportNo" value="<?php echo $passport ?>" <?php if($action=="4") echo "disabled"; ?> size="15" />
                                  <input type="text" name="txtuserid"  id="txtuserid" value="
								  <?php 
								  	if($userid=="0")
									{ 
										echo $userid;
									}
									else
									{
										echo $userid;
									} 
								  ?>" style="display:none"></font></p>
                      <p align="left" style="text-align: left; margin-bottom:0em"><b><font size="2"> NACIONALIDAD</font></b><font size="2">-Nationality &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="Arial, Helvetica, sans-serif">
                        <input type="text" name="txtNationality" value="<?php echo $nationality ?>" <?php if($action=="4") echo "disabled"; ?> size="15" />
                    <input type="text" name="txtappid"  id="txtappid" value="<?php echo $appid ?>" style="display:none"></font></p></td>
                </tr>
                <tr>
                  <td align="left" colspan="8" valign="top" height="76"><p align="left" style="text-align: left"> <b><font size="2">PAIS NATAL</font></b><font size="2">-Country 
                    of birth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="Arial, Helvetica, sans-serif">
                                    <input type="text" name="txtCountry" value="<?php echo $country ?>" <?php if($action=="4") echo "disabled"; ?> size="15" />
                                </font></p><p align="left" style="text-align: left"><font size="2"> CIUDAD-City
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="Arial, Helvetica, sans-serif"><input type="text" name="txtCity" value="<?php echo $city ?>" <?php if($action=="4") echo "disabled"; ?> size="15" />
                  </font></p></td>
                </tr>
                <tr>
                  <td align="left" colspan="8" valign="top"><font size="2">FECHA 
                    DE NACIMIENTO-Date of Birht</font></td>
                </tr>
                <tr>
                  <td align="left" colspan="3" valign="top"><font size="2">DIA-DAY</font><font face="Arial, Helvetica, sans-serif"><input type="text" name="txtDay" value="<?php echo $day ?>" <?php if($action=="4") echo "disabled"; ?> size="5" /></font></td>
                  <td colspan="2" align="left" valign="top"><font size="2">MES-MONTH</font><font face="Arial, Helvetica, sans-serif"><input type="text" name="txtMonth" value="<?php echo $month ?>" <?php if($action=="4") echo "disabled"; ?> size="5" /></font></td>
                  <td align="left" height="27" valign="top" colspan="3"><font size="2">Ano-YEAR</font><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtYear" value="<?php echo $year ?>" <?php if($action=="4") echo "disabled"; ?> size="5" /></font></td>
      			</tr>
                <tr>
                  <td align="center" colspan="8" height="33"><p align="center" style="text-align: center"> <font size="2" color="#000000">DIRECCION POSTAL 
                    - Mailing Address</font></p></td>
                </tr>
                <tr>
                  <td align="center" colspan="4" height="152" valign="top"><p align="center" style="text-align: center; line-height:12px"> <font size="2" color="#000000">SOLICITANTE 
                    -Applicant</font></p>
                      <p align="center" style="text-align: center; line-height:12px"> <b> <font size="2" color="#000000">Embassy of Panama 
                        In Singapore</font></b></p>
                    <p align="center" style="text-align: center; line-height:12px"> <b> <font size="2" color="#000000">16 Raffles Qauy,#41-06</font></b></p>
                    <p align="center" style="text-align: center; line-height:12px"> <b> <font size="2" color="#000000">Hong Leong 
                      Building</font></b></p>
                    <p align="center" style="text-align: center; line-height:12px"> <b> <font size="2" color="#000000">Singapore 048581</font></b></p></td>
                  <td align="center" colspan="4" height="152" valign="top"><p align="center" style="text-align: center"> <font size="2" color="#000000">EMPLEADOR-Employer</font></p>
                      <p align="left" style="text-align: left"><font color="#000000" face="Arial, Helvetica, sans-serif">
                        <textarea rows="6" name="txtEmployerAddress" <?php if($action=="4") echo "disabled"; ?> cols="38"><?php echo $address; ?></textarea>
                    </font></p></td>
                </tr>
                <tr>
                  <td align="center" colspan="8" valign="middle"><p align="center" style="text-align: center"> <font size="2" color="#000000">CARACTERISTICAS 
                    DEL CERTIFICADO SOLICITADO- Detail of 
                    Certificate of Competency requested</font></p></td>
                </tr>
                <tr>
                  <td align="center" colspan="2" height="33" valign="top"><p align="center" style="text-align: center"> <font size="2">FUNCTION-Function</font></p></td>
                  <td colspan="2" height="33" align="center" valign="top"><p align="center" style="text-align: center"><font size="2">NIVEL- 
                    Level</font></p></td>
                  <td colspan="4" height="33" align="center" valign="top"><p align="center" style="text-align: center"><font size="2"> LIMITACIONES-Limitations Applying(if any)</font></p></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtFunction1" value="<?php echo $fun1; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="2" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtLevel1" value="<?php echo $level1; ?>" <?php if($action=="4") echo "disabled"; ?> size="35" />
                  </font></td>
                  <td colspan="4" align="left"><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtFuncLimit1" value="<?php echo $funclimit1; ?>" <?php if($action=="4") echo "disabled"; ?> size="61" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtFunction2" value="<?php echo $fun2; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="2" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtLevel2" value="<?php echo $level2; ?>" <?php if($action=="4") echo "disabled"; ?> size="35" />
                  </font></td>
                  <td colspan="4" align="left"><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtFuncLimit2" value="<?php echo $funclimit2; ?>" <?php if($action=="4") echo "disabled"; ?> size="61" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtFunction3" value="<?php echo $fun3; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="2" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtLevel3" value="<?php echo $level3; ?>" <?php if($action=="4") echo "disabled"; ?> size="35" />
                  </font></td>
                  <td colspan="4" align="left"><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtFuncLimit3" value="<?php echo $funclimit3; ?>" <?php if($action=="4") echo "disabled"; ?> size="61" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtFunction4" value="<?php echo $fun4; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="2" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtLevel4" value="<?php echo $level4; ?>" <?php if($action=="4") echo "disabled"; ?> size="35" />
                  </font></td>
                  <td colspan="4" align="left"><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtFuncLimit4" value="<?php echo $funclimit4; ?>" <?php if($action=="4") echo "disabled"; ?> size="61" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtFunction5" value="<?php echo $fun5; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="2" align="left" valign="middle"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtLevel5" value="<?php echo $level5; ?>" <?php if($action=="4") echo "disabled"; ?> size="35" />
                  </font></td>
                  <td colspan="4" align="left"><font face="Arial, Helvetica, sans-serif">
                      <input type="text" name="txtFuncLimit5" value="<?php echo $funclimit5; ?>" <?php if($action=="4") echo "disabled"; ?> size="61" />
                  </font></td>
                </tr>
                <tr>
                  <td align="center" colspan="2"><p align="center" style="text-align: center"> <font size="2">CARGO -Capacity</font></p></td>
                  <td colspan="6" align="center"><p align="center" style="text-align: center"><font size="2"> LIMITACIONES(si ias hubiere)-Limitations 
                    Applying(if any)</font></p></td>
                </tr>
                <tr>
                  <td align="left" colspan="2" height="28"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtCargo1" value="<?php echo $cargo1; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="6" align="left" height="28"><font face="Arial, Helvetica, sans-serif">
                    <input name="txtCargoLimit1" size="104" value="<?php echo $cargolimit1; ?>" <?php if($action=="4") echo "disabled"; ?> style="float: left" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtCargo2" value="<?php echo $cargo2; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="6" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input name="txtCargoLimit2" size="104" value="<?php echo $cargolimit2; ?>" <?php if($action=="4") echo "disabled"; ?> style="float: left" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtCargo3" value="<?php echo $cargo3; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="6" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input name="txtCargoLimit3" size="104" value="<?php echo $cargolimit3; ?>" <?php if($action=="4") echo "disabled"; ?> style="float: left" />
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="text" name="txtCargo4" value="<?php echo $cargo4; ?>" <?php if($action=="4") echo "disabled"; ?> size="40" />
                  </font></td>
                  <td colspan="6" align="left"><font face="Arial, Helvetica, sans-serif">
                    <input name="txtCargoLimit4" size="104" value="<?php echo $cargolimit4; ?>" <?php if($action=="4") echo "disabled"; ?> style="float: left" />
                  </font></td>
                </tr>
                <tr>
                  <td align="center" colspan="4"><p align="left" style="line-height: 200%; margin-bottom: 0em"> <font size="2" color="#000000">SI ES PERSONAL 
                    SUBALTERNO INDIQUE CATGO SOLICITADO IF YOU ARE RATING 
                    INDICATE POSITION</font></p></td>
                  <td align="left" colspan="4"><p align="left"> <font face="Arial, Helvetica, sans-serif">
                      <input name="txtIndicatePOS" size="61" value="<?php echo $indicatepos; ?>" <?php if($action=="4") echo "disabled"; ?> style="float: left" />
                  </font></p></td>
                </tr>
                <tr>
                  <td align="center" colspan="8" height="33"><p align="left"><font size="2" color="#000000"> ENDORSOS A SOLICITAR - REQUEST ENDORSEMENT</font></p></td>
                </tr>
                <tr>
                </table>
                <table border="0" width="953" id="table2" height="auto">
                  <td align="center" colspan="8">
					<p align="left"><font size="2">Capitulo -Chapter V</font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6" height="22"><font size="2">1-Rela V/1Buques Tanqueros 
                    -Regulation V/1 Tankers ship STCW/95</font></td>
                  <td align="right" width="20" height="22" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="Cap[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $cap1; ?> value="cap1"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">A-Petrolers-Oil Tankers</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="Cap[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $cap2; ?>  value="cap2"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6" height="22"><font size="2">B-Quimiqueros -Chemical Tankers</font></td>
                  <td align="right" width="20" height="22" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="Cap[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $cap3; ?>  value="cap3"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">C-Gaseros-Liquified Gas Tankers</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="Cap[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $cap4; ?>  value="cap4"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6" height="22"><font size="2">2-Regla V/1 Buques Tanqueros-Regulation 
                    V/1 Tankers ship STCW78/95</font></td>
                  <td align="right" height="22" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="Cap[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $cap5; ?>  value="cap5"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">3-Regla V/2 Buques de pasajeros 
                    de transbordo rodado-Regulation V/2 Ro-Ro 
                    Passengers ships STCW78/95</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="Cap[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $cap6; ?>  value="cap6"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="8">
					CURSOS REQUERIDOS POR EL SOLICITANTE EN BASE AL 
                    STCW-78/95
                       <br>SPECIAL TRAINING REQUIREMENTS ACCORDING TO STCW 78/95
                </tr>
                <tr>
                  <td align="left" colspan="6" height="32"><font size="2">1-Regla VI/1 
                    familiarization,formacion e instruccion basica 
                    para la gente de mar en aspectos de seguridad</font> <font size="2" color="#000000">Regulation VI/1 
                      Familiarization,basic safety training and 
                      instruction for all seafarers</font></td>
                  <td align="right" height="32" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain1; ?> value="spec1"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">2-Regla VI/2 Suficiencia en el 
                    manejo de Supervivencia, botes de Rescate y 
                    botes de Rescate rapidos</font> <font size="2" color="#000000">Regulation VI/2 
                      Certificates of proficienty in survival craft 
                      rescue boats and fast rescue boats</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                  <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain2; ?> value="spec2"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6" height="22"><font size="2">3-Regla VI/3 Tecnicas avanzadas 
                    de lucha contra incendio-Regulation VI/3 
                    Training in&nbsp; advance fire fighting</font></td>
                  <td align="right" height="22" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain3; ?> value="spec3"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">4-Regla VI/4 Primeros Auxillios u 
                    cuidados medicos-Regulation VI/4 Medical first 
                    aid and medical care</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain4; ?> value="spec4"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6" height="23"><font size="2">5-Curso de Operador GMSSM-GMDSS 
                    Operator Course</font></td>
                  <td align="right" height="23" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain5; ?> value="spec5"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6" height="22"><font size="2">6-Curso de Radar-Radar Course</font></td>
                  <td align="right" width="20" height="22" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain6; ?> value="spec6"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">7-ARPA</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain7; ?> value="spec7"/>
                  </font></td>
                </tr>
                <tr>
                  <td align="left" colspan="6"><font size="2">8-Otros-Other</font></td>
                  <td align="right" width="20" colspan="2"><font face="Arial, Helvetica, sans-serif">
                    <input type="checkbox" name="SpecialTrain[]" <?php if($action=="4") echo "disabled"; ?> <?php echo $specialtrain8; ?> value="spec8"/>
                  </font></td>
                </tr>
                <tr>
                </table>
                <table border="0" width="858" id="table3" height="auto">
                  <td align="left" colspan="4"><p align="left"><font size="2" color="#000000"> Support Documents(jpeg/pdf maximum size 2MB)</font></p></td>
                </tr>
                <tr>
                  <td align="left" width="211" height="27"><font size="2">Photo <a href="<?php echo $filelink1; ?>" target=_blank> <img src="<?php echo $showfile1; ?>" height="42" width="42" /> </a>
				  </font>
                  <font face="Arial, Helvetica, sans-serif">
                    <input type="file" name="upfile[]" size="24" value="<?php echo $file1; ?>" style="float: left" <?php if($action=="4") echo "disabled"; ?> /></font></td>
                  <td align="left" height="27" width="264">
                 	<font size="2">Passport <a href="<?php echo $filelink2; ?>" target=_blank> <img src="<?php echo $showfile2; ?>" height="42" width="42" /></a>
                    </font>
                  <font face="Arial, Helvetica, sans-serif">
                    <input type="file" name="upfile[]" size="24" value="<?php echo $file2; ?>" style="float: left" <?php if($action=="4") echo "disabled"; ?> /></font></td>
                  <td align="left" height="27" width="427">
                 
                  <font size="2">Other Support Documents <a href="<?php echo $filelink3; ?>" target=_blank> <img src="<?php echo $showfile3; ?>" height="42" width="42" /></a>
                  </font><font face="Arial, Helvetica, sans-serif">
                  <input type="file" name="upfile[]" size="24"  value="<?php echo $file3; ?>" style="float: left" <?php if($action=="4") echo "disabled"; ?> /></font></td>
                  <td align="left" height="27" width="0">&nbsp;
                 
                  </td>
                </tr>
                <tr>
                  <td align="left" colspan="4">
                  	<p>
					<input type="text" name="txtfile1" size="20" style="display:none" value="<?php echo $file1; ?>"><input type="text" name="txtfile2" size="20"  style="display:none" value="<?php echo $file2; ?>"><input type="text" name="txtfile3" size="20"  style="display:none" value="<?php echo $file3; ?>"></td>
                </tr>
                <tr>
                  <td align="right" colspan="3" width="733" height="43"> <font face="Arial, Helvetica, sans-serif">
                      </p>
					<script type="text/javascript" language="javascript">
						function logout()
						{
							location.href="onlinevisa.php";
						}
						function gotoapplist()
						{
							var guserid=document.getElementById("txtuserid").value;
							if(guserid==0)
							{
								location.href="appadmin.php?userid="+guserid+"&appid=&action=";
							}
							else
							{
								location.href="applist.php?userid="+guserid+"&appid=&action=";	
							}
						}
						function printform()
						{
							var guseridp=document.getElementById('txtuserid').value;
							var gappidp=document.getElementById('txtappid').value;
							//alert("Hello");
							//var w = window.open('');
							//w.location.href='visaformprint.php?userid='+guseridp+'&appid='+gappidp+'&action=4';
							window.open('visaformprint.php?userid='+guseridp+'&appid='+gappidp+'&action=4','_blank','Print Visa Form','height=1600,width=1600,top=0,left=0,toolbar=no,menubar=no,resizable=no,location=no, status=no');
							//location.href="applist.php?userid="+guseridp+"&appid=&action=";
						}
						function printblankform()
						{
							var guseridp=document.getElementById('txtuserid').value;
							var gappidp=document.getElementById('txtappid').value;
							//alert("Hello");
							//var w = window.open('');
							//w.location.href='visaformprint.php?userid='+guseridp+'&appid='+gappidp+'&action=4';
							window.open('blankvisaformprint.php?userid='+guseridp+'&appid='+gappidp+'&action=4','_blank','Print Visa Form','height=1600,width=1600,top=0,left=0,toolbar=no,menubar=no,resizable=no,location=no, status=no');
							//location.href="applist.php?userid="+guseridp+"&appid=&action=";
						}
						</script></font>
					<p style="text-align: center"> <font face="Arial, Helvetica, sans-serif">
                      <input type="submit" value="Submit" name="submit" <?php if($action=="4") echo "disabled" ?>><input type="submit" value="Save Draft" name="savedraft" <?php if($action=="4") echo "disabled"; ?>><input type="reset" value="Clear" name="clear" <?php if($action=="4") echo "disabled"; ?>><input type="button" value="Go to Application List" name="gotolist" id="gotolist" onclick="gotoapplist()" <?php if($action=="4" and $userid=0) echo "disabled"; ?>><input type="button" value="Print" name="printvisaform" id="printvisaform" onclick="printform()" <?php if($action=="1") echo "disabled"; ?>><input type="button" value="Print Blank Form" name="printblankvisaform" id="printblankvisaform" onclick="printblankform()" style="display:none"><input type="button" value="Sign Out" name="signout" id="signout" onclick="logout()"></font></td>
                  <td align="right" width="0" height="43">&nbsp; </td>
                </tr>
              </table>
          </form>
        </div>
      </div>
    </div>
  </div>
  <? include('footer.php') ?>
</div>
<?php
	require("include/class.phpmailer.php");
	$submit=$_POST["submit"];
	$savedraft=$_POST["savedraft"];
	$userid=$_POST["txtuserid"];
	$appid=$_POST["txtappid"];
	
	if($appid=="")
	{
		/*Generate New AppID*/
		$appid=date("Y").date("m").date("d").date("H").date("i").date("s");
	}
	if(isset($submit))
    {
		/*
		echo "<script language=javascript>alert('Submit ".$submit.$savedraft."');</script>";
		echo "<script language=javascript>alert('Submit ".$userid."');</script>";
		*/
		if (saveapp($userid,$appid))
		{
			$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
			$strsel="Delete From visa_applist Where userid=".$userid." and appid='".$appid."'";
			$query = phpmkr_query($strsel,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strsel);
			$strsel="insert into visa_applist values(".$userid.",'".$appid."',now(),2)";
			$query = phpmkr_query($strsel,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strsel);
			
			/*Email to Admin*/
			/*Send Email*/
			$mail = new phpmailer();
			$uniq_id = md5(uniqid(time()));
			//$mail->SetLanguage('en', "language/");
			$mail->IsSMTP();
			$mail->IsHTML();
			$mail->From     = FROM_EMAIL;
			$mail->FromName = FROM_NAME;
			$mail->Host     = EW_SMTPSERVER;
			$mail->SMTPAuth = true;     // turn on SMTP authentication
			$mail->Username = EW_SMTPSERVER_USERNAME;  // SMTP username
			$mail->Password = EW_SMTPSERVER_PASSWORD; // SMTP password	
			$mail->Subject=" Licence Application"; 
			
			// HTML body
			
			$body  = "Hello You Have Received a New Application, <p>";
			$body .= "<i>Your</i> can click ";
			$body .= "<a href='".EW_SERVER_ROOT."appform.php?userid=0&appid=".$appid."&action=4&viewuser=".$userid."'>View New Application</a> to open it.<br>";
			$body .= "Please do not reply this Email.<br>";
			$body .= "Sincerely, <br>";
			$body .= "Panama Online Maritime Service";
			
			$body .="<p><img src='".EW_SERVER_ROOT."images/ACMEFocus-TN.jpg'/></p>";
		
			// Plain text body (for mail clients that cannot read HTML)
			/*
			$text_body  = "Hello Eric Wang, \n\n";
			$text_body .= "Your personal photograph to this message.\n\n";
			$text_body .= "Sincerely, \n";
			$text_body .= "phpmailer List manager";
			*/
			//$body = embed_images($body);
			$mail->Body    = $body;
			$mail->AltBody = $text_body;
			$mail->AddAddress(TO_ADMIN_EMAIL);
			//$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
			
			if(!$mail->Send())
			{
				echo "Mailer Error: " . $mail->ErrorInfo;
			}
			else
			{
				
			}
			// Clear all addresses and attachments for next loop
			$mail->ClearAddresses();
			$mail->ClearAttachments();
			/*Email to Admin*/
			/*Email to User*/
			$strsel="Select * From visa_user where userid=".$userid."";
			$query = phpmkr_query($strsel,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strsel);
			$row = @phpmkr_fetch_array($query);
			$strEmail=$row["username"];
			$strFirstName==$row["firstname"];
			$strLastName==$row["lastname"];
			$uniq_id = md5(uniqid(time()));
			//$mail->SetLanguage('en', "language/");
			$mail->IsSMTP();
			$mail->IsHTML();
			$mail->From     = FROM_EMAIL;
			$mail->FromName = FROM_NAME;
			$mail->Host     = EW_SMTPSERVER;
			$mail->SMTPAuth = true;     // turn on SMTP authentication
			$mail->Username = EW_SMTPSERVER_USERNAME;  // SMTP username
			$mail->Password = EW_SMTPSERVER_PASSWORD; // SMTP password	
			$mail->Subject="Panama Online Maritime Service"; 
			// HTML body
			
			$body  = "Hello <font size=\"4\">". $strFirstName ." ". $strLastName ."</font>, <p>";
			$body .= "<i>Your</i> have submitted your Application Successful.<p>";
			$body .= "Your Application ID is <font size=\"4\">".$appid."</font>.Please Keep it Carefully for your reference.<br>";
			$body .= "Please do not reply this Email.<br>";
			$body .= "Sincerely, <br>";
			$body .= "Panama Online Maritime Service";
		
			// Plain text body (for mail clients that cannot read HTML)
			/*
			$text_body  = "Hello Eric Wang, \n\n";
			$text_body .= "Your personal photograph to this message.\n\n";
			$text_body .= "Sincerely, \n";
			$text_body .= "phpmailer List manager";
			*/
		
			$mail->Body    = $body;
			$mail->AltBody = $text_body;
			$mail->AddAddress($strEmail);
			//$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
			
			if(!$mail->Send())
			{
				echo "Mailer Error: " . $mail->ErrorInfo;
			}
			else
			{
				
			}
			// Clear all addresses and attachments for next loop
			$mail->ClearAddresses();
			$mail->ClearAttachments();
			/*Email to User*/
			/*echo "<script language=javascript>alert('Submit Successful!Application ID is ".$appid."!');</script>";*/
			/**/
			$url="submitted.php?userid=".$userid."&appid=".$appid."&action=";
			header("Location: $url");
		}
		else
		{
			
		}
	}
	if(isset($savedraft))
    {
		
		/*
		echo "<script language=javascript>alert('Save Draft ".$savedraft.$submit."');</script>";
		*/
		if (saveapp($userid,$appid))
		{
			$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
			$strsel="Delete From visa_applist Where userid=".$userid." and appid='".$appid."'";
			$query = phpmkr_query($strsel,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strsel);
			$strsel="insert into visa_applist values(".$userid.",'".$appid."',now(),1)";
			$query = phpmkr_query($strsel,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strsel);
			
			/*echo "<script language=javascript>alert('Save Draft Successful!Application ID is ".$appid."!');</script>";*/
			$url="applist.php?userid=".$userid."&appid=&action=";
			header("Location: $url");
			
		}
		else
		{
			
		}
	}
?>
<?php
function saveapp($userid,$appid)
{	
	$saveapp=false;
	/*
	echo "<script language=javascript>alert('Submit save userid ".$userid."');</script>";
	echo "<script language=javascript>alert('Submit save appid ".$appid."');</script>";
	*/
	
	$oldfile1=$_POST["txtfile1"];
	$oldfile2=$_POST["txtfile2"];
	$oldfile3=$_POST["txtfile3"];
	
	$firstname=$_POST["txtFirstName"];
	$middlename=$_POST["txtMiddleName"];
	$surname=$_POST["txtSurname"];
	$passport=$_POST["txtPassportNo"];
	$nationality=$_POST["txtNationality"];
	$country=$_POST["txtCountry"];
	$city=$_POST["txtCity"];
	$day=$_POST["txtDay"];
	$month=$_POST["txtMonth"];
	$year=$_POST["txtYear"];
	$address=$_POST["txtEmployerAddress"];
	$fun1=$_POST["txtFunction1"];
	$fun2=$_POST["txtFunction2"];
	$fun3=$_POST["txtFunction3"];
	$fun4=$_POST["txtFunction4"];
	$fun5=$_POST["txtFunction5"];
	$level1=$_POST["txtLevel1"];
	$level2=$_POST["txtLevel2"];
	$level3=$_POST["txtLevel3"];
	$level4=$_POST["txtLevel4"];
	$level5=$_POST["txtLevel5"];
	$funclimit1=$_POST["txtFuncLimit1"];
	$funclimit2=$_POST["txtFuncLimit2"];
	$funclimit3=$_POST["txtFuncLimit3"];
	$funclimit4=$_POST["txtFuncLimit4"];
	$funclimit5=$_POST["txtFuncLimit5"];
	$cargo1=$_POST["txtCargo1"];
	$cargo2=$_POST["txtCargo2"];
	$cargo3=$_POST["txtCargo3"];
	$cargo4=$_POST["txtCargo4"];
	$cargolimit1=$_POST["txtCargoLimit1"];
	$cargolimit2=$_POST["txtCargoLimit2"];
	$cargolimit3=$_POST["txtCargoLimit3"];
	$cargolimit4=$_POST["txtCargoLimit4"];
	$indicatepos=$_POST["txtIndicatePOS"];
	$cap= array("","","","","",""); 
	$checkbox=$_POST["Cap"];
	//$strcap=implode(",",$cap);
	//只返回选中的
	for($i=0;$i<count($checkbox);$i++)
    {
	   if($checkbox[$i]==="")
	   {
	   
	   }
	   else
	   {
	      if($checkbox[$i]==="on")
		  {
		  
		  }
		  else
		  {   
		     $iNum=substr($checkbox[$i],-1,1);
			 $iCount=$iNum-1;
		     $cap[$iCount]="checked";
		  }
	   } 
    }
	/*
	$cap[0]=($cap[0]="cap1"?"checked":"");
	$cap[1]=($cap[1]="cap2"?"checked":"");
	$cap[2]=($cap[2]="cap3"?"checked":"");
	$cap[3]=($cap[3]="cap4"?"checked":"");
	$cap[4]=($cap[4]="cap5"?"checked":"");
	$cap[5]=($cap[5]="cap6"?"checked":"");
	*/
	$specialtrain= array("","","","","","","",""); 
	$checkbox1=$_POST["SpecialTrain"];
	//$strspeicaltrain=implode(",",$specialtrain);
	for($i=0;$i<count($checkbox1);$i++)
    {
	   if($checkbox1[$i]==="")
	   {
	   
	   }
	   else
	   {
	      if($checkbox1[$i]==="on")
		  {
		  
		  }
		  else
		  {   
		     $iNum=substr($checkbox1[$i],-1,1);
			 $iCount=$iNum-1;
		     $specialtrain[$iCount]="checked";
		  }
	   } 
    }
	/*
	$specialtrain[0]=($specialtrain[0]="on"?"checked":"");
	$specialtrain[1]=($specialtrain[1]="on"?"checked":"");
	$specialtrain[2]=($specialtrain[2]="on"?"checked":"");
	$specialtrain[3]=($specialtrain[3]="on"?"checked":"");
	$specialtrain[4]=($specialtrain[4]="on"?"checked":"");
	$specialtrain[5]=($specialtrain[5]="on"?"checked":"");
	$specialtrain[6]=($specialtrain[6]="on"?"checked":"");
	$specialtrain[7]=($specialtrain[7]="on"?"checked":"");
	*/
	/*File Upload*/
	//如果收到表单传来的参数,则进行上传处理,否则显示表单
	if(isset($_FILES['upfile']))
	{
		//建目录函数,其中参数$directoryName最后没有"/",
		//要是有的话,以'/'打散为数组的时候,最后将会出现一个空值 
		function makeDirectory($directoryName) 
		{
			$directoryName = str_replace("\\","/",$directoryName);
			$dirNames = explode('/', $directoryName);
			$total = count($dirNames) ;
			$temp = '';
			for($i=0; $i<$total; $i++) 
			{
				$temp .= $dirNames[$i].'/';
				if (!is_dir($temp)) 
				{
					$oldmask = umask(0);
					if (!mkdir($temp, 0777)) exit("Can not Create temporary folder $temp"); 
					umask($oldmask);
				}
			}
			return true;
		}

		if($_FILES['upfile']['name'] <> "")
		{
			//包含上传文件类
			require_once ("./include/class.upload.file.php");
			//设置文件上传目录
			$savePath = "visattach";
			//创建目录
			makeDirectory($savePath);
			//允许的文件类型
			$fileFormat = array('gif','jpg','jpge','png','pdf');
			//文件大小限制,单位: Byte,1KB = 1000 Byte
			//0 表示无限制,但受php.ini中upload_max_filesize设置影响
			$maxSize = 0;
			//覆盖原有文件吗? 0 不允许  1 允许 
			$overwrite = 0;
			//初始化上传类
			$f = new Upload( $savePath, $fileFormat, $maxSize, $overwrite);
			//如果想生成缩略图,则调用成员函数 $f->setThumb();
			//参数列表: setThumb($thumb, $thumbWidth = 0,$thumbHeight = 0)
			//$thumb=1 表示要生成缩略图,不调用时,其值为 0
			//$thumbWidth  缩略图宽,单位是像素(px),留空则使用默认值 130
			//$thumbHeight 缩略图高,单位是像素(px),留空则使用默认值 130
			//不生成缩略图
			//$f->setThumb(1);
	
			//参数中的uploadinput是表单中上传文件输入框input的名字
			//后面的0表示不更改文件名,若为1,则由系统生成随机文件名
			if (!$f->run('upfile',1))
			{
				//通过$f->errmsg()只能得到最后一个出错的信息,
				//详细的信息在$f->getInfo()中可以得到。
				echo $f->errmsg()."<br>\n";
			}
			//上传结果保存在数组returnArray中。
			//echo "<pre>";
			//print_r($f->getInfo());
			//echo "</pre>";
			//Get File Name
			$f->getInfo();
			if ($f->returnArray[0]["name"]!="")
			{
				$photofile=$f->returnArray[0]["saveName"];	
			}
			else
			{
				$photofile=$oldfile1;
			}
			if ($f->returnArray[1]["name"]!="")
			{
				$passportfile=$f->returnArray[1]["saveName"];	
			}
			else
			{
				$passportfile=$oldfile2;
			}
			if ($f->returnArray[2]["name"]!="")
			{
				$otherfile=$f->returnArray[2]["saveName"];	
			}
			else
			{
				$otherfile=$oldfile3;
			}
		}
	}
	else
	{
	
	}
	/*File Upload*/
	/*echo "<script language=javascript>alert('Submit save cap".$cap[0]."');</script>";*/
	$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
	/*Delete Previous Record*/
	$strdel="Delete From visa_form Where userid=".$userid." and appid='".$appid."'";
	$query = phpmkr_query($strdel,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strdel);
	/*Save New App*/
	$strsave="Insert Into visa_form values(".$userid.",'".$appid."','".$firstname."','".$middlename."','".$surname."','".$passport."','".$nationality."','".$country."','".$city."',".$day.",".$month.",".$year.",'".$address."','".$fun1."','".$fun2."','".$fun3."','".$fun4."','".$fun5."','".$level1."','".$level2."','".$level3."','".$level4."','".$level5."','".$funclimit1."','".$funclimit2."','".$funclimit3."','".$funclimit4."','".$funclimit5."','".$cargo1."','".$cargo2."','".$cargo3."','".$cargo4."','".$cargolimit1."','".$cargolimit2."','".$cargolimit3."','".$cargolimit4."','".$indicatepos."','".$cap[0]."','".$cap[1]."','".$cap[2]."','".$cap[3]."','".$cap[4]."','".$cap[5]."','".$specialtrain[0]."','".$specialtrain[1]."','".$specialtrain[2]."','".$specialtrain[3]."','".$specialtrain[4]."','".$specialtrain[5]."','".$specialtrain[6]."','".$specialtrain[7]."','".$photofile."','".$passportfile."','".$otherfile."')";
	$query = phpmkr_query($strsave,$conn) or die("Failed to execute query at line " . __LINE__ . ": " . phpmkr_error($conn) . '<br>SQL: ' . $strsave);
	return true;
}

function embed_images(&$body)
{
    // get all img tags
    preg_match_all('/<img.*?>/', $body, $matches);
    if (!isset($matches[0])) return;
    // foreach tag, create the cid and embed image
    $i = 1;
    foreach ($matches[0] as $img)
    {
        // make cid
        $id = 'img'.($i++);
        // replace image web path with local path
        preg_match('/src="(.*?)"/', $body, $m);
        if (!isset($m[1])) continue;
        $arr = parse_url($m[1]);
        if (!isset($arr['host']) || !isset($arr['path']))continue;
        // add
        $this->AddEmbeddedImage('/home/username/'.$arr['host'].'/public'.$arr['path'], $id, 'attachment', 'base64', 'image/jpeg');
        $body = str_replace($img, '<img alt="" src="cid:'.$id.'" style="border: none;" />', $body);
    }
}

?>
</body>
</html>