	<script type="text/javascript" src="<?php echo $thisPage; ?>js/messages.js"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo $thisPage; ?>css/messages.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo $thisPage; ?>css/captcha.css" />
	<script>
	    function validate(form) {
		    var companyName = form.companyName.value;
		    if(companyName == "") {
			    inlineMsg("companyName","Company Name Harus Diisi.",2);
			    return false;
		    } else {
			    var targetdiv = document.getElementById("companyName"); 
			    targetdiv.style.backgroundColor = "white";
		    }
		    return true;
	    }	
	</script>	
    
    <?php
	$idEvent = "ConfirmExhibitor";    
	$addExhibitor = (isset($_POST["addExhibitor"]) ? $_POST["addExhibitor"] : null);
	$ctr = 0;
	
    if ($addExhibitor == "Add Exhibitor") {		
        $companyName = (isset($_POST["companyName"]) ? $_POST["companyName"] : null);
		if ($companyName) {
            $query = 
            " select * from exhibitor_list ".
            " where LOWER(companyName)=LOWER('$companyName')";
            if (mysqli_num_rows($result=mysqli_query($conn, $query)) > 0) {
                while ($row = mysqli_fetch_array($result)) {
                    echo '<p><strong>Record sudah ada.</strong></p>';
                    echo '
                    <form name="formSubmit" id="formSubmit" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">
                        <input type="hidden" name="exhibitorID" id="exhibitorID" value="'.$row["exhibitorID"].'" />
                        <input type="submit" name="btnSubmit" id="btnSubmit" class="button" value="Click to Continue">
                    </form>';
                }
            } else {                
                $sql1 = 
                " insert into exhibitor_list ".
                " values (null, '".$companyName."') ";
                //echo "<br>sql: ".$sql;
                if (mysqli_query($conn, $sql1)) {
                    $exhibitorID = mysqli_insert_id($conn);
                    echo '
                    <form name="formAddExhibitor" id="formAddExhibitor" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">
                        <input type="hidden" name="exhibitorID" id="exhibitorID" value="'.$exhibitorID.'" />
                    </form>';
                    echo '
                    <script type="text/javascript">
                        document.getElementById(\'formAddExhibitor\').submit(); 
                    </script>';
                }	
        
            }                
        }
	} else if ($addExhibitor == "Update Data") {		
		$exhibitorID = (isset($_POST["exhibitorID"]) ? $_POST["exhibitorID"] : null);
        $sql1 = 
        " select labelType, labelName, designName from form_label, form_design ".
        " where labelType='".$idEvent."' and labelID = labelParentID ".
        " order by designORDER asc ";
		//echo "<br>sql: ".$sql;
		if ($hasil1 = mysqli_query($conn, $sql1)) {
			while ($data1 = mysqli_fetch_array($hasil1)) {
				if ($data1["labelName"] == "Company Name") {
                    $ctr++;
                    $labelName = $data1["labelName"];
                    $designName = $data1["designName"];
                    $$designName = $_POST[$designName];    
                }
			}
			$sql3 = 
            " UPDATE exhibitor_list ".
            " SET companyName = '$companyName' ".
            " WHERE  exhibitorID = '$exhibitorID' ";
			//echo $sql3;
			if (mysqli_query($conn, $sql3)) {
                echo '
                <form name="formUpdateExhibitor" id="formUpdateExhibitor" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">
                    <input type="hidden" name="exhibitorID" id="exhibitorID" value="'.$exhibitorID.'" />
                </form>';
                echo '
                <script type="text/javascript">
                    document.getElementById(\'formUpdateExhibitor\').submit(); 
                </script>';
            }
		}	
	} else {
        ?>
        <h3>Add Exhibitor</h3>
        <?php
        echo '
        <form name="formAddExhibitor" id="formAddExhibitor" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" method="post">';
        $sql = 
        " select * from form_label ".
        " where labelType='$idEvent'";
        //echo "<br> sql".$sql; 
        if ($hasil = mysqli_query($conn, $sql)) {		
            while ($rec = mysqli_fetch_array($hasil)) {
                echo "<h2 class='h2-teasers'>".$rec["labelNameTitle"]."</h2>";
                $sql2 = "select * from form_design, form_element where elementID = element AND labelParentID = ".$rec["labelID"]." order by designORDER asc";
                // echo $sql2;
                if ($hasil2 = mysqli_query($conn, $sql2)) {
                    echo '<table width="100%" cellpadding="10" cellspacing="1" border="0" bgcolor="#999999">';
                    while ($rec2 = mysqli_fetch_array($hasil2)) {
                        // Link ke Element
                        //echo $elementSubStat;
                        if ($rec2["labelName"] == "Company Name") {
                            if ($rec2["elementName"] != "hidden") {
                                //echo "$designName : ".$$designName;
                                echo '<tr valign="middle" bgcolor="#e4e4e4">';
                                echo '	<td width=25% style="background-color:#e4e4e4;">
                                            <strong>
                                                '.$rec2["labelName"];
                                                if ($rec2["labelNameEng"]) {
                                                    echo '
                                                    (<i>'.$rec2["labelNameEng"].'</i>)';
                                                }
                                            echo '	
                                            </strong>													
                                        </td>';
                                echo '	<td style="background-color:#e4e4e4;">';
                                            echo '<input style="width:96%; height:30px; padding: 8px; font-size:18px" ';
                                            echo 'type="'.$rec2["elementName"].'" 
                                                  name="'.$rec2["designName"].'" 
                                                  id="'.$rec2["designName"].'" 
                                                  value="">';
                                echo '	</td>';
                                echo '</tr>';
                            }
                        }
                    }
                    echo '</table>';
                }
            }
        }
        ?>
        <table width="100%" cellpadding="15" cellspacing="1" border="0">
            <tr>
                <td align="center">
                    <input type="hidden" name="action" id="action" value="addRecord" />
                    <input type="submit" name="addExhibitor" id="addExhibitor" class="button" value="Add Exhibitor">
                </td>
            </tr>
        </table>
        <?php
        echo '
        </form>';
    }
	?>