/var/www/hkosl.com/alliancealliance/webadmin/course_add.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
    
require_once('check_login.php');

    
$messgae "";

    if(empty(
$_POST["code"])){
        
$messgae .= "Please enter code.\\n\\n";
    }

    if(empty(
$_POST["start_date"])){
        
$messgae .= "Please enter start date.\\n\\n";
    }else{
        if(!
validateDate($_POST["start_date"], "Y-m-d")){
            
$messgae .= "Invalid start date format.\\n\\n";
        }
    }

    if(empty(
$_POST["end_date"])){
        
$messgae .= "Please enter end date.\\n\\n";
    }else{
        if(!
validateDate($_POST["end_date"], "Y-m-d")){
            
$messgae .= "Invalid end date format.\\n\\n";
        }
    }

    if(empty(
$_POST["fee"])){
        
$messgae .= "Please enter fee.\\n\\n";
    }else{
        if(!
is_numeric($_POST["fee"]) || (float)($_POST["fee"] <= 0)){
            
$messgae .= "Fee should be in digital format and larger than 0.\\n\\n";
        }
    }

    if(empty(
$_POST["training_center_id"])){
        
$messgae .= "Please select a venue.\\n\\n";
    }

    if(empty(
$_POST["time"])){
        
$messgae .= "Please enter time.\\n\\n";
    }

    if(empty(
$_POST["medium_of_instruction_en"])){
        
$messgae .= "Please enter medium of instruction.\\n\\n";
    }

    if(empty(
$_POST["stop_applying_text_en"])){
        
$messgae .= "Please enter stop applying text.\\n\\n";
    }

    if(!empty(
$messgae)){
        echo 
"<script>alert('".$messgae."'); history.back();</script>";
        exit;
    }

    if(isset(
$_POST["valid_apply"]) && $_POST["valid_apply"] == 1){
        
$valid_apply 1;
    }else{
        
$valid_apply 0;
    }

    
$sql        "insert into course set course_category_id=?, code =?, start_date=?, end_date=?, fee=?, training_center_id=?, time=?, valid_apply=?, createdate=?, createby=?, lastupdate=?, lastupby=?, ";
    
$parameters = array($_POST["course_category_id"], $_POST["code"], $_POST["start_date"], $_POST["end_date"], $_POST["fee"], implode(",",$_POST["training_center_id"]), $_POST["time"], $valid_apply$nowdate$_SESSION['cmsloginid'], $nowdate$_SESSION['cmsloginid']);

    foreach (
$arraylangcode as $langcode => $langname) {
        
$sql .= "medium_of_instruction_" $langcode "=?, stop_applying_text_" $langcode "=?, ";
        
$parameters[] = $_POST["medium_of_instruction_" $langcode];
        
$parameters[] = $_POST["stop_applying_text_" $langcode];
    }

    
$sql substr_replace($sql"", -2);
    
bind_pdo($sql$parameters);

    
$dbh null;

    
header("Location: course_index.php?msg=1");