for ($i = 0; $i < sizeof($_POST['titles']); $i++) {
        $name[$i] = $_FILES['files']['name'][$i];
        $tmp_name = $_FILES['files']['tmp_name'][$i];
        $ext = $obj->getExtension($name[$i]);
        $newName = $obj->nameGen();
        $finalName[$i] = $newName . "." . $ext;
        move_uploaded_file($tmp_name, "attachements/purchaser_attach/" . $finalName[$i]);
    }
    if (isset($_GET['val']) == 1 && $_GET['val'] != "") {
        $update_purchaser = $obj->purchase_update($_POST, $finalName, $name, $result['id'], $_SESSION['pin_id'], $_SESSION['pin_table']);
        if ($update_purchaser == 1) {
            $obj->ALertMessage("Purchaser Updated Successfully", $update_purchaser);
            $obj->redirect("purchaser_update.php");
        }
    } else {
        $purchaser = $obj->purchaser_registration($_POST, $finalName, $name, $_SESSION['pin_id'], $_SESSION['pin_table']);
        $obj->ALertMessage("Purchaser registered", $purchaser);
    }
}
$_SESSION['key'] = mt_rand(1, 1000);
?>
<!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" />
<script type="text/javascript" src="main_includes/add_new_row.js"></script>

<link rel="stylesheet" href="main_css/main_css.css"/>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600' rel='stylesheet' type='text/css'>
<title><?php 
if ($_GET['val'] != "") {