当前位置: 首页>>代码示例>>PHP>>正文


PHP Check::checkInput方法代码示例

本文整理汇总了PHP中Check::checkInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Check::checkInput方法的具体用法?PHP Check::checkInput怎么用?PHP Check::checkInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Check的用法示例。


在下文中一共展示了Check::checkInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 function login()
 {
     if (!empty($_POST)) {
         $check = new Check();
         $user = new User();
         $pdo = new Db();
         $db = $pdo->get();
         $mapper = new Mapper($db);
         //Проверяем входные данные
         $user->login = $check->checkInput($_POST['login']);
         $password = $check->checkInput($_POST['pass']);
         $user->password = md5($password);
         //Если пользователь не найден
         $this->user = $mapper->select($user);
         if (empty($this->user)) {
             $this->error = "Пароль или логин не совпадают";
             $this->out('login.php');
         } else {
             $this->out('profile.php');
             //Если найден, выводим профиль
         }
     } else {
         $this->out('login.php');
     }
 }
开发者ID:toppestkek,项目名称:Test,代码行数:25,代码来源:ctrlIndex.php

示例2: function

<?php

$app->get('/add', function () use($app) {
    $main = '';
    $add = 'active';
    return $app['twig']->render('add.twig', array('main' => $main, 'add' => $add));
});
$app->post('/add', function () use($app) {
    if (isset($_POST)) {
        $check = new Check();
        $name = $check->checkInput($_POST['name']);
        $comment = $check->checkInput($_POST['comment']);
        $pdo = new Db();
        $db = $pdo->get();
        $validate = new Validate($db);
        $data = array('name' => $name, 'comment' => $comment);
        $errors = $validate->getErrors($data);
        if (!empty($errors)) {
            $main = '';
            $add = 'active';
            return $app['twig']->render('add.twig', array('main' => $main, 'add' => $add, 'errors' => $errors, 'name' => $name, 'comment' => $comment));
        } else {
            $mapper = new Mapper($db);
            $ip_address = $_SERVER['REMOTE_ADDR'];
            $comments = new Comments();
            $comments->name = $name;
            $comments->comment = $comment;
            $comments->ip_address = $ip_address;
            $mapper->save($comments);
            return $app->redirect('/GuestBook/');
        }
开发者ID:toppestkek,项目名称:GuestBook,代码行数:31,代码来源:add.php

示例3: Mapper

    $db = $pdo->get();
    $mapper = new Mapper($db);
    $data = $mapper->select();
    $dir = '';
    return $app['twig']->render('index.twig', array('main' => $main, 'add' => $add, 'data' => $data, 'dir' => $dir));
})->bind('homepage');
$app->post('/', function () use($app) {
    if (isset($_POST['likeOption']) || isset($_POST['dateOption'])) {
        $main = 'active';
        $add = '';
        $pdo = new Db();
        $db = $pdo->get();
        $comments = new Comments();
        $check = new Check();
        if (isset($_POST['likeOption'])) {
            $order = $check->checkInput(htmlspecialchars($_POST['likeOption']));
            $comments->orderby = 'likes';
        }
        if (isset($_POST['dateOption'])) {
            $order = $check->checkInput(htmlspecialchars($_POST['dateOption']));
            $comments->orderby = 'date';
        }
        $mapper = new Mapper($db);
        if ($order == 'ASC') {
            $data = $mapper->searchAsc($comments);
        } else {
            $data = $mapper->searchDesc($comments);
        }
        $dir = '';
        return $app['twig']->render('index.twig', array('main' => $main, 'add' => $add, 'dir' => $dir, 'data' => $data));
    }
开发者ID:toppestkek,项目名称:GuestBook,代码行数:31,代码来源:index.php


注:本文中的Check::checkInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。