コード例 #1
0
     $errors['year_month'] = "* year month cannot be empty.";
 } elseif (!preg_match("/^[0-9]{6}\$/", $_POST['year_month'])) {
     $errors['year_month'] = "* Invalied year month.";
 }
 if (empty($_POST['date'])) {
     $errors['date'] = "* Date cannot be empty.";
 }
 if (empty($_POST['weight'])) {
     $errors['weight'] = "* weight cannot be empty.";
 }
 if (empty($errors)) {
     $cus_id = trim(mysql_prep($_POST['cuz_id']));
     $year_month = trim(mysql_prep($_POST['year_month']));
     $weight = trim(mysql_prep($_POST['weight']));
     $date = trim(mysql_prep($_POST['date']));
     $td = new T_data();
     $td->cus_id = $cus_id;
     $td->year_month = $year_month;
     $td->date = $date;
     $td->weight = $weight;
     global $database;
     $result = mysql_query("SELECT * FROM user WHERE id='{$cus_id}' AND  privilege='Customer'");
     $rowExist = mysql_num_rows($result) > 0;
     $rslt = "";
     if (!$rowExist) {
         echo '<script language="javascript">';
         echo 'alert("error! Invalied Customer ID!")';
         echo '</script>';
     } else {
         $rslt = $td->enter_t_data();
     }
コード例 #2
0
if (isset($_POST['submit'])) {
    if (empty($_POST['year_month'])) {
        $errors['year_month'] = "* year month cannot be empty.";
    } elseif (!preg_match("/^[0-9]{6}\$/", $_POST['year_month'])) {
        $errors['year_month'] = "* Invalied year month.";
    }
    if (empty($_POST['rate'])) {
        $errors['rate'] = "* Rate cannot be empty.";
    }
    if (empty($errors)) {
        $year_month = trim(mysql_prep($_POST['year_month']));
        $rate = trim(mysql_prep($_POST['rate']));
        $bill = new Bill();
        $bill->year_month = $year_month;
        $bill->rate = $rate;
        $td = new T_data();
        $td->year_month = $year_month;
        $td->cal_totals();
        $rslt = $bill->cal_bill();
        /*
        $result = mysql_query("SHOW TABLES LIKE '$year_month'");
        $tableExist = mysql_num_rows($result) > 0;
        
        
        if(!$tableExist){
        	echo '<script language="javascript">';
        	echo 'alert("error! First calculate the total weights!")';
        	echo '</script>';
        	
        }else{
        	$td->cal_totals();