本文整理汇总了PHP中isPostRequest函数的典型用法代码示例。如果您正苦于以下问题:PHP isPostRequest函数的具体用法?PHP isPostRequest怎么用?PHP isPostRequest使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isPostRequest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cart_list
function cart_list()
{
$data = array();
if (!isset($_SESSION['cart'])) {
$data['error'] = 'Giỏ trống trơn!';
} else {
$data['cart'] = $_SESSION['cart'];
$fromDB = model('book')->getCartList($data['cart']);
$merge = array();
foreach ($data['cart'] as $cart) {
foreach ($fromDB as $value) {
if (intval($value['id']) == $cart['book_id']) {
$merge[] = array_merge($cart, $value);
}
}
}
//var_dump($merge);
$data['merge'] = $merge;
}
//Submit cart
if (isPostRequest()) {
$postData = postData();
for ($i = 1; $i <= count($_SESSION['cart']); $i++) {
foreach ($_SESSION['cart'] as $key => $cart) {
if ($postData['bookid' . $i] == $cart['book_id']) {
$_SESSION['cart'][$key]['quantity'] = $postData['quantity' . $i];
}
}
}
redirect('index.php?c=bill&m=view');
}
$data['template_file'] = 'cart/list.php';
render('layout.php', $data);
}
示例2: bill_detail
function bill_detail()
{
$data = array();
$user = adminLogged();
if (!adminLogged()) {
redirect('/index.php?c=admin&m=login');
} else {
$bill_detail = model('bill')->getBillDetails($_GET['id']);
$data['total'] = 0;
foreach ($bill_detail as $key => $b) {
$book = model('book')->getSingle($b['book_id']);
$bill_detail[$key]['name'] = $book['name'];
$bill_detail[$key]['price'] = intval($book['price']);
$bill_detail[$key]['total'] = $book['price'] * $b['quantity'];
$bill_detail[$key]['image'] = $book['image'];
$data['total'] += $book['price'] * $b['quantity'];
}
$data['bill_detail'] = $bill_detail;
}
$data['statuses'] = array('Chờ duyệt', 'Đang giao hàng', 'Đã giao hàng', 'Hủy');
$data['stt'] = model('bill')->getOneBy($_GET['id'], null)['status'];
if (isPostRequest()) {
$postData = postData();
db_update('bills', $postData, 'id=' . $_GET['id']);
$data['stt'] = $postData['status'];
$data['error'] = 'Tình trạng đơn hàng update thành công.';
}
$data['user'] = model('user')->getOneBy(model('bill')->getOneBy($_GET['id'], null)['user_id'], null);
$data['template_file'] = 'bill/detail.php';
render('layout.php', $data);
}
示例3: user_signup
function user_signup()
{
if (isPostRequest()) {
$arr_user = array('user_name' => $_POST['user_name'], 'name' => $_POST['name'], 'password' => md5($_POST['password']));
model('user')->signup($arr_user);
redirect('index.php');
}
$data['template_file'] = 'user/signup.php';
render('layout.php', $data);
}
示例4: news_add
function news_add()
{
$data = array();
if (isPostRequest()) {
$postData = postData();
$currentUser = isLogged();
if (model('news')->addToUser($postData, $currentUser['id'])) {
redirect('index.php?c=news&m=list.php');
}
}
$data['template_file'] = 'news/add.php';
render('layout.php', $data);
}
示例5: test_feedback
function test_feedback()
{
$data = array();
if (isPostRequest()) {
$postData = postData();
$currentUser = isLogged();
// echo "<pre>";;var_dump($postData);die();
if (model('question')->addToUser($postData, $currentUser['id'])) {
redirect('index.php?c=test&m=list');
}
}
$data['template_file'] = 'test/feedback.php';
render('test.php', $data);
}
示例6: admin_login
function admin_login()
{
$data = array();
if (isPostRequest()) {
$postData = postData();
if (model('admin')->adminLogin($postData)) {
redirect('/admin/index.php?c=bill&m=list');
} else {
$data['error'] = 'Login failed! Please try again!';
}
}
$data['template_file'] = 'admin/login.php';
render('layout.php', $data);
}
示例7: auth_register
function auth_register()
{
$data = array();
$data['template_file'] = 'auth/register.php';
if (isPostRequest()) {
$postData = postData();
if (model('user')->authRegister($postData)) {
redirect('index.php?c=payment&m=list');
} else {
$data['error'] = 'Register failed ! Email exists ! Please try again !';
$data['postData'] = $postData;
}
}
render('layout.php', $data);
}
示例8: auth_register
function auth_register()
{
sleep(1);
$data = array();
if (isPostRequest()) {
$postData = postData();
if (model('user')->aut_register($postData)) {
redirect('/blogtaolao_MVC_/index.php');
} else {
$data['error'] = 'Email đã tồn tại ';
}
}
$data['template_file'] = 'auth/register.php';
render('layout.php', $data);
}
示例9: blog_detail
function blog_detail()
{
$id = $_GET['id'];
if (isPostRequest()) {
$postData = postData();
$currentUser = isLogged();
if (model('blog')->addComment($postData, $id)) {
redirect('/index.php?c=blog&m=detail&id=' . $id);
}
}
$data['blog_content'] = model('blog')->getOneBlog($id);
$data['blog_comment'] = model('blog')->getAllComment($id);
//var_dump($data);die;
$data['template_file'] = 'blog/viewBlog.php';
render('layout.php', $data);
}
示例10: blog_update
function blog_update()
{
$data = array();
if (isPostRequest()) {
$postData = postData();
$currentUser = isLogged();
if ($currentUser && model('entry')->update($postData, $_GET['entry'])) {
redirect('/index.php?c=blog&m=list');
}
} else {
$data['single'] = model('entry')->getSingle($_GET['entry']);
}
$data['title'] = 'Chỉnh sửa bài viết';
$data['template_file'] = 'entry/add.php';
render('layout.php', $data);
}
示例11: auth_change_info
function auth_change_info()
{
$logged = isLogged();
$email = $logged['email'];
$role = $logged['role'];
if (isPostRequest()) {
$postData = postData();
//var_dump($postData);die;
if (model('user')->authChangeInfo($postData, $email, $role)) {
redirect('/index.php?c=blog&m=list');
}
}
$data['user_info'] = model('user')->authGetInfo($email);
//var_dump($data);die;
$data['template_file'] = 'auth/change_info.php';
render('layout.php', $data);
}
示例12: book_list
function book_list()
{
$data = array();
if (isset($_GET['pagenum'])) {
$pagenum = $_GET['pagenum'];
} else {
$pagenum = 0;
}
$data['books'] = model('book')->get12($pagenum);
if (model('book')->getCount() % 12 === 0) {
$data['pages'] = intval(model('book')->getCount()) / 12;
} else {
$data['pages'] = intval(model('book')->getCount() / 12) + 1;
}
$data['pagenum'] = $pagenum;
//Thêm vào giỏ hàng:
if (isPostRequest()) {
$postData = postData();
$id = intval($postData['aidi']);
$quantity = intval($postData['quantity']);
if ($quantity <= 0) {
$data['info'] = 'Số lượng không đúng!';
} else {
if (!isset($_SESSION['cart'])) {
$_SESSION['cart'][0] = array('book_id' => $id, 'quantity' => $quantity);
} else {
$flag = false;
foreach ($_SESSION['cart'] as $cart) {
if ($cart['book_id'] === $id) {
//$cart['quantity'] += $quantity;
$flag = true;
$data['info'] = 'Sách này đã có trong giỏ hàng!';
break;
}
}
if ($flag == false) {
$_SESSION['cart'][] = array('book_id' => $id, 'quantity' => $quantity);
$data['info'] = 'Thêm sách vào giỏ hàng thành công!';
}
}
}
}
//var_dump($_SESSION['cart']);
$data['template_file'] = 'book/list.php';
render('layout.php', $data);
}
示例13: book_update
function book_update()
{
$data = array();
if (isPostRequest()) {
$postData = postData();
$currentUser = adminLogged();
if ($currentUser && model('book')->update($postData, $_GET['bookid'], $_SERVER['DOCUMENT_ROOT'] . '/images/') === 'success') {
redirect('/admin/index.php?c=book&m=list');
} else {
$data['error'] = model('book')->update($postData, $_GET['bookid'], $_SERVER['DOCUMENT_ROOT'] . '/images/');
$data['single'] = model('book')->getSingle($_GET['bookid']);
}
} else {
$data['single'] = model('book')->getSingle($_GET['bookid']);
$_SESSION['oldImage'] = $data['single']['image'];
}
$data['title'] = 'Chỉnh sửa sách';
$data['template_file'] = 'book/add.php';
render('layout.php', $data);
}
示例14: product_add
function product_add()
{
if (isPostRequest()) {
$postData = postData();
$postData['image'] = uploadImage();
$currentUser = isLogged();
//var_dump($postData);die;
if ($postData['image'] == 0) {
echo "Không upload được hình ảnh";
} else {
if (model('product')->addProduct($postData)) {
redirect('/index.php?c=product&m=list');
} else {
echo "<script>alert('" . "Không thêm vào được CSDL!" . "')</script>";
}
}
}
$data['template_file'] = 'product/add.php';
render('layout.php', $data);
}
示例15: bill_view
function bill_view()
{
$data = array();
if (!isset($_SESSION['cart'])) {
redirect('index.php?c=cart&m=list');
} else {
$data['cart'] = $_SESSION['cart'];
$fromDB = model('book')->getCartList($data['cart']);
$merge = array();
foreach ($data['cart'] as $cart) {
foreach ($fromDB as $value) {
if (intval($value['id']) == $cart['book_id']) {
$merge[] = array_merge($cart, $value);
}
}
}
$total = 0;
foreach ($merge as $m) {
$total += $m['quantity'] * $m['price'];
}
$data['total'] = $total;
}
if (isLogged()) {
$data['user'] = $_SESSION['logged'];
}
if (isset($_GET['update'])) {
$data['update'] = 1;
}
if (isPostRequest()) {
$postData = postData();
if (model('user')->update($postData, $postData['email'])) {
$data['user'] = model('user')->getOneBy($postData['email'], 'email');
unset($data['user']['password']);
$_SESSION['logged'] = $data['user'];
unset($_GET['update']);
redirect('index.php?c=bill&m=view');
}
}
$data['template_file'] = 'bill/view.php';
render('layout.php', $data);
}