/** * 添加类别 * * @param array $data 类别信息数组 */ public function add(array $data) { $node['cate_name'] = $data['cate_name']; $node['parent_id'] = $data['parent_id']; $node['sort_order'] = $data['sort_order']; $node['is_show'] = $data['is_show']; if (!empty($data['cate_id'])) { // 导入数据需要设定id $node['cate_id'] = $data['cate_id']; } $this->db->insert('category', $node); $lastId = $this->db->lastInsertId(); // 更新路径信息 $path = $this->getPath($node['parent_id']) . "{$lastId};"; $where = $this->db->quoteInto('cate_id = ?', $lastId); $this->db->update('category', array('path' => $path), $where); $this->_allCates = null; }
echo "Database Connection Error! " . $e->getMessage(); } } public function insert($table_name, $form_data = NULL) { $fields = implode(',', array_keys($form_data)); $value = implode(',', array_fill(0, count($form_data), '?')); $sth = $this->conn->prepare("INSERT INTO {$table_name} ({$fields}) VALUES ({$value})"); $sth->execute(array_values($form_data)); return true; } } $obj = new obj(); $code = substr(md5(rand()), 0, 45); if (isset($_POST['submit'])) { $to = $_POST['email']; $subject = 'the subject'; $message = 'http://raymund.com/lectureclip/resetpass.php?d=' . $code; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $data = array('gen_code' => $code); $obj->insert("tbl_forgot_pass_log ", $data); mail($to, $subject, $message, $headers); echo 'send'; } ?> <form action="" method="post"> <input type="text" name="email"> <input type="submit" name="submit"> </form>
function saveFBdetails() { $obj = new obj(); $data = false; $_SESSION['fb_login'] = true; $_SESSION['fb_lastname'] = $_POST['fb_lastname']; $_SESSION['fb_firstname'] = $_POST['fb_firstname']; $_SESSION['fb_email'] = $_POST['fb_email']; $_SESSION['fb_pic'] = $_POST['fb_pic']; //CHECK IF EMAIL EXISTS $checkUser = $obj->singleData($_SESSION['fb_email'], "email", "tbl_ut_pass"); if ($checkUser != NULL) { extract($checkUser); //IF ALREADY HAVE LC ACCOUNT if ($usertype == 1) { $usertype = 3; $fb_update = array('usertype' => $usertype); $obj->update('tbl_ut_pass', $fb_update, "WHERE uid = " . $uid); $_SESSION['uid'] = $uid; } else { $_SESSION['uid'] = $uid; } } else { $usertype = 2; $obj->newReg($_SESSION['fb_firstname'], $_SESSION['fb_lastname'], "tbl_ut_user"); foreach ($obj->showLastId("tbl_ut_user", "uid") as $value) { extract($value); $_SESSION['uid'] = $value['uid']; } $fb_data = array('uid' => $uid, 'email' => $_SESSION['fb_email'], 'usertype' => $usertype); $obj->insert('tbl_ut_pass', $fb_data); } $_SESSION['user_lastname'] = $_POST['fb_lastname']; $_SESSION['user_firstname'] = $_POST['fb_firstname']; $_SESSION['user_pic'] = $_POST['fb_pic']; $data = $_SESSION['uid']; echo json_encode($data); }
function __autoload($class) { include_once '../lib/' . $class . '.php'; } $form = new validator(); $obj = new obj(); if (isset($_POST['submit'])) { $name_cat = $_POST['name_category']; $name_cat_error = $form->walang_laman($name_cat, "Category"); $errors = $name_cat_error; if (!isset($_POST['form_key']) || !$obj->validate()) { $error = 'Invalid Token!'; } else { if (empty($errors)) { $data = array('catname' => $name_cat); $obj->insert('tbl_m_category', $data); $success = "yesssssssssssss"; } } } //echo $_SESSION['form_key']; echo $error ? $error : ''; echo $success ? $success : ''; ?> <form action="" method="post"> <?php $obj->outputKey(); ?> <input type="text" name="name_category"> <?php echo $errors ? $errors : '';
/** * Cadastra u novo registro * @param array $data * @return array */ private static function insert($data) { return self::$psy->insert($data); }