示例#1
0
    $msg = "Incomplete Parameters";
    $data = array();
} else {
    $user_ids = json_decode($uid);
    foreach ($user_ids as $k => $val) {
        $sql = "SELECT * from buddyup where user_id=:user_id and kid_id=:kid_id";
        $sth = $conn->prepare($sql);
        $sth->bindValue('kid_id', $kid_id);
        $sth->bindValue('user_id', $val);
        try {
            $sth->execute();
        } catch (Exception $e) {
        }
        $res[$k] = $sth->fetchAll(PDO::FETCH_ASSOC);
        if (!count($res[$k])) {
            $user = DataClass::getUserIds($val);
            $email = $user[0]['email'];
            $sql = "INSERT INTO `buddyup` (`id`, `user_id`, `kid_id`,`buddy_code`,`created_on`) VALUES (DEFAULT, :user_id, :kid_id,:buddy_code,NOW())";
            $sth = $conn->prepare($sql);
            $sth->bindValue('buddy_code', $code);
            $sth->bindValue('kid_id', $kid_id);
            $sth->bindValue('user_id', $val);
            try {
                $sth->execute();
                $success = '1';
                $msg = 'Buddy Code sent.';
                $msg1 = "Buddy Code for Jobstars";
                //DataClass::sendEmail($email,$msg1,$code,SMTP_EMAIL);
            } catch (Exception $e) {
            }
        } else {