當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Input::getString方法代碼示例

本文整理匯總了PHP中Input::getString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Input::getString方法的具體用法?PHP Input::getString怎麽用?PHP Input::getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Input的用法示例。


在下文中一共展示了Input::getString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: pageController

function pageController()
{
    if (Auth::isLoggedIn()) {
        header("Location: index.php");
        exit;
    }
    try {
        $email = Input::getString('email');
    } catch (Exception $e) {
        $email = '';
    }
    try {
        $password = Input::getString('password');
    } catch (Exception $e) {
        $password = '';
    }
    $user = UserModel::findByEmail($email);
    // if(empty($user))
    // {
    //  header("Location: users.create.php");
    //   exit();
    // }
    if (Auth::attempt($user, $password)) {
        Auth::setSessionVariables($user);
        header("Location: index.php");
        exit;
    }
    return array('email' => $email, 'loggedIn' => Auth::isLoggedIn());
}
開發者ID:LZJCodeup,項目名稱:AdLister,代碼行數:29,代碼來源:auth.login.php

示例2: pageController

function pageController()
{
    $errors = [];
    if (!Auth::isLoggedIn()) {
        header('Location: users.create.php');
        exit;
    }
    $userObject = UserModel::find($_SESSION['user_id']);
    if (!empty($_POST)) {
        try {
            $userObject->first_name = Input::getString('firstName');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $userObject->last_name = Input::getString('lastName');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (Input::get('password1') == Input::get('password2')) {
            try {
                $userObject->password = Input::getPassword('password1', $userObject->first_name, $userObject->last_name, $userObject->email);
            } catch (Exception $e) {
                $errors[] = $e->getMessage();
            }
        }
        $userObject->save();
    }
    return ['user' => $userObject, 'errors' => $errors];
}
開發者ID:LZJCodeup,項目名稱:AdLister,代碼行數:30,代碼來源:users.edit.php

示例3: processForm

function processForm($postImage)
{
    $errors = [];
    $errors['count'] = 0;
    $today = date("Y-m-d");
    //pass this to be inserted into the database
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $category = Input::getString('category');
        } catch (Exception $e) {
            $errors['category'] = 'Category: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $postingTitle = Input::getString('title');
        } catch (Exception $e) {
            $errors['title'] = 'Posting Title: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $price = Input::getNumber('price');
        } catch (Exception $e) {
            $errors['price'] = 'Price: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            $errors['description'] = 'Description: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $date_posted = Input::getDate('date_posted');
        } catch (Exception $e) {
            $errors['date_posted'] = 'Date Posted: ' . $e->getMessage();
            $errors['count']++;
        }
        if ($errors['count'] == 0) {
            $adObject = new AdModel();
            $adObject->category = $category;
            $adObject->title = $postingTitle;
            $adObject->price = $price;
            $adObject->description = $description;
            var_dump($postImage);
            $adObject->image = $postImage;
            $adObject->date_posted = $today;
            // hardcoded:  $adObject->user_id = $_SESSION['user_id'];
            $adObject->users_id = 1;
            $adObject->save();
            //unset the $_SESSION['image'] - will be using the one in the database
            unset($_SESSION['image']);
            header("Location: /ads.show.php?id=" . $adObject->id);
            //this will be the $_GET for the ads.show.php
            die;
        }
    }
    return $errors;
}
開發者ID:LZJCodeup,項目名稱:AdLister,代碼行數:59,代碼來源:ads.create.php

示例4: insertPost

function insertPost($dbc)
{
    //Setting username (currently hard coded, will use SESSION variable later)
    $username = "pascal456";
    $user = User::findUserByUsername($username);
    var_dump($user);
    $userid = $user->userid;
    $errors = [];
    try {
        $title = Input::getString('title');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $description = Input::getString('description');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $location = Input::getString('location');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $email = Input::getString('email');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $price = Input::getString('price');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    if (Input::has('title')) {
        if ($_FILES) {
            // Create variable for the uploads direc for images in our server
            $uploads_directory = 'img/uploads/';
            $filename = $uploads_directory . basename($_FILES['image']['name']);
            if (move_uploaded_file($_FILES['image']['tmp_name'], $filename)) {
                // echo '<p>The file '. basename( $_FILES['image']['name']). ' has been uploaded.</p>';
            } else {
                //alert("Sorry, there was an error uploading your file.");
            }
        }
    }
    $date = date('Y-m-d');
    $insert_table = "INSERT INTO posts (userid, post_date, title, price, description, email, location, image) VALUES (:userid, :post_date, :title, :price, :description, :email, :location, :image)";
    $stmt = $dbc->prepare($insert_table);
    $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
    $stmt->bindValue(':post_date', $date, PDO::PARAM_STR);
    $stmt->bindValue(':title', $title, PDO::PARAM_STR);
    $stmt->bindValue(':price', $price, PDO::PARAM_STR);
    $stmt->bindValue(':description', $description, PDO::PARAM_STR);
    $stmt->bindValue(':email', $email, PDO::PARAM_STR);
    $stmt->bindValue(':location', $location, PDO::PARAM_STR);
    $stmt->bindValue(':image', $filename, PDO::PARAM_STR);
    $stmt->execute();
    return $errors;
}
開發者ID:sakrog,項目名稱:listmorecoals,代碼行數:59,代碼來源:ads.index.php

示例5: getPasswordMatch

 public static function getPasswordMatch()
 {
     try {
         return Input::getString('passwordmatch', 0, 50);
     } catch (Exception $e) {
         self::addError($e->getMessage());
     }
 }
開發者ID:adlisterproject,項目名稱:sketchy-b,代碼行數:8,代碼來源:ValidateUser.php

示例6: getContact

 public static function getContact()
 {
     try {
         return Input::getString('contact', 0, 50);
     } catch (Exception $e) {
         self::addError($e->getMessage());
     }
 }
開發者ID:adlisterproject,項目名稱:sketchy-b,代碼行數:8,代碼來源:ValidateAd.php

示例7: insertPark

function insertPark($dbc, $park)
{
    $errorsArray = [];
    try {
        $name = Input::getString('name');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    try {
        $location = Input::getString('location');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    try {
        $date_established = Input::getDate('date_established');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    try {
        $area = Input::getNumber('area');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    try {
        $visitors = Input::getString('visitors');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    try {
        $description = Input::getString('description');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    if (!empty($errorsArray)) {
        return $errorsArray;
    }
    $query = "INSERT INTO national_parks (name, location, date_established, area, visitors, description)\n\t\t\t\tVALUES (:name, :location, :date_established, :area, :visitors, :description)";
    $query = $dbc->prepare($query);
    $query->bindValue(':name', $name, PDO::PARAM_STR);
    $query->bindValue(':location', $location, PDO::PARAM_STR);
    $query->bindValue(':date_established', $date_established, PDO::PARAM_STR);
    $query->bindValue(':area', $area, PDO::PARAM_STR);
    $query->bindValue(':visitors', $visitors, PDO::PARAM_STR);
    $query->bindValue(':description', $description, PDO::PARAM_STR);
    // $query->fetchAll(PDO::FETCH_ASSOC);
    $query->execute();
}
開發者ID:ryanski,項目名稱:Codeup-Web-Exercises,代碼行數:53,代碼來源:national_parks.php

示例8: processForm

function processForm($adObject, $postImage)
{
    $errors = [];
    $errors['count'] = 0;
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $postingTitle = Input::getString('title');
        } catch (Exception $e) {
            $errors['title'] = 'Posting Title: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $price = Input::getNumber('price');
        } catch (Exception $e) {
            $errors['price'] = 'Price: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            $errors['description'] = 'Description: ' . $e->getMessage();
            $errors['count']++;
        }
        if ($errors['count'] == 0) {
            //update the database
            // $adObject = new AdModel();
            $adObject->title = $postingTitle;
            $adObject->price = $price;
            $adObject->description = $description;
            $adObject->id = $_GET['id'];
            if ($postImage == "Database Image") {
                //no image was uploaded - use the database image
                $adObject->image = $adObject->image;
            } else {
                //new image uploaded - use new image
                $adObject->image = $postImage;
            }
            var_dump("adObject image: " . $adObject->image . "!");
            $adObject->date_posted = $adObject->date_posted;
            $adObject->category = $adObject->category;
            // hardcoded:  $adObject->user_id = $_SESSION['user_id'];
            $adObject->users_id = $_SESSION['user_id'];
            //this is hardcoded for now
            $adObject->save();
            unset($_SESSION['image']);
            header("Location: /ads.show.php?id=" . $adObject->id);
            //this will be the $_GET for the ads.show.php
            die;
        }
    }
    return $errors;
}
開發者ID:LZJCodeup,項目名稱:AdLister,代碼行數:53,代碼來源:ads.edit.php

示例9: updateData

function updateData($dbc)
{
    $errors = [];
    if (!empty($_POST)) {
        try {
            $userName = Input::getString('username');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $password = Input::getString('pwd');
            $password = password_hash($password, PASSWORD_DEFAULT);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $firstName = Input::getString('firstname');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $lastName = Input::getString('lastname');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $email = Input::getString('email');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $zipCode = Input::getNumber('zipcode');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (Input::notEmpty('username') && Input::notEmpty('pwd') && Input::notEmpty('firstname') && Input::notEmpty('lastname') && Input::notEmpty('email') && Input::notEmpty('zipcode')) {
            // create new instance of user class
            $user = new User();
            $user->first_name = $firstName;
            $user->last_name = $lastName;
            $user->user_name = $userName;
            $user->email = $email;
            $user->zipcode = $zipCode;
            $user->save();
            $_SESSION['logInMessage'] = "Your profile has been updated.!!!";
            header("Location:index.php");
            die;
        }
    }
    return $errors;
}
開發者ID:adlistercodeup,項目名稱:RNC-Ad-Lister,代碼行數:51,代碼來源:users.edit.php

示例10: processForm

function processForm()
{
    $errors = [];
    $errors['count'] = 0;
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $firstName = Input::getString('first_name');
        } catch (Exception $e) {
            $errors['first_name'] = 'First Name: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $lastName = Input::getString('last_name');
        } catch (Exception $e) {
            $errors['last_name'] = 'Last Name: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $email = Input::getString('email');
        } catch (Exception $e) {
            $errors['email'] = 'Email Address: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            if ($_POST['password1'] != $_POST['password2']) {
                throw new UnexpectedValueException("Do Not Match!");
            }
            $passwordOneHashed = Input::getPassword('password1', $firstName, $lastName, $email);
        } catch (Exception $e) {
            $errors['password1'] = 'Password: ' . $e->getMessage();
            $errors['count']++;
        }
        if ($errors['count'] == 0) {
            //no errors - add to the database
            $userObject = new UserModel();
            $userObject->first_name = $firstName;
            $userObject->last_name = $lastName;
            $userObject->email = $email;
            $userObject->password = $passwordOneHashed;
            $userObject->save();
            header("Location: /users.show.php?id=" . $userObject->id);
            //this will be the $_GET for the users.show.php
            die;
        }
    }
    return $errors;
}
開發者ID:LZJCodeup,項目名稱:AdLister,代碼行數:48,代碼來源:users.create.php

示例11: insertPark

function insertPark($dbc)
{
    $errors = [];
    try {
        $date = Input::getDate('date_established');
        $d = $date->format('Y-m-d');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['date_established'], $e->getMessage());
    }
    try {
        $name = Input::getString('name');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['name'], $e->getMessage());
    }
    try {
        $location = Input::getString('location');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['location'], $e->getMessage());
    }
    try {
        $area_in_acres = Input::getNumber('area_in_acres');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['area_in_acres'], $e->getMessage());
    }
    try {
        $description = Input::getString('description');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['description'], $e->getMessage());
    }
    if ($error) {
        echo $error;
        print_r($errors);
    } else {
        $insert = "INSERT INTO national_parks (name, location, date_established, area_in_acres, description)\n\tVALUES (:name, :location, :date_established, :area_in_acres, :description)";
        $stmt = $dbc->prepare($insert);
        $stmt->bindValue(':name', $name, PDO::PARAM_STR);
        $stmt->bindValue(':location', $location, PDO::PARAM_STR);
        $stmt->bindValue(':date_established', $d, PDO::PARAM_STR);
        $stmt->bindValue(':area_in_acres', $area_in_acres, PDO::PARAM_STR);
        $stmt->bindValue(':description', $description, PDO::PARAM_STR);
        $stmt->execute();
    }
}
開發者ID:aer3934,項目名稱:Codeup-Web-Exercises,代碼行數:48,代碼來源:national_parks.php

示例12: insertData

function insertData($dbc)
{
    $errors = [];
    if (!empty($_POST)) {
        try {
            $name = Input::getString('name');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $location = Input::getString('location');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $date = Input::getDate('date_established');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $area = Input::getNumber('area_in_acres');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (Input::notEmpty('name') && Input::notEmpty('location')) {
            $userData = 'INSERT INTO national_parks (name, location, date_established, area_in_acres, description)
							VALUES (:name, :location, :date_established, :area_in_acres, :description)';
            $userStmt = $dbc->prepare($userData);
            $userStmt->bindValue(':name', $name, PDO::PARAM_STR);
            $userStmt->bindValue(':location', $location, PDO::PARAM_STR);
            $userStmt->bindValue(':date_established', $date, PDO::PARAM_STR);
            $userStmt->bindValue(':area_in_acres', $area, PDO::PARAM_STR);
            $userStmt->bindValue(':description', $description, PDO::PARAM_STR);
            try {
                $userStmt->execute();
            } catch (Exception $e) {
                $errors[] = $e->getMessage();
                throw new Exception('Error: {$e->getMessage()}');
            }
        }
    }
    return $errors;
}
開發者ID:Reni789,項目名稱:Codeup-Web-Exercises,代碼行數:48,代碼來源:national_parks.php

示例13: insertpark

function insertpark($dbc)
{
    $name = Input::getString('parkname', 2, 100);
    $location = Input::getString('parklocation', 2, 100);
    $date = Input::getDate('date', '1776-07-04', '9999-01-01');
    $area = Input::getNumber('area', 0, 1000000000000);
    $description = Input::getString('parkdescription', 2, 10000);
    $inner = 'INSERT INTO national_parks (name, location, date_established, area_in_acres, description) VALUES (:name, :location, :date_established, :area_in_acres, :description)';
    $query = $dbc->prepare($inner);
    $query->bindValue(':name', $name, PDO::PARAM_STR);
    $query->bindValue(':location', $location, PDO::PARAM_STR);
    $query->bindValue(':date_established', $date, PDO::PARAM_INT);
    $query->bindValue(':area_in_acres', $area, PDO::PARAM_INT);
    $query->bindValue(':description', $description, PDO::PARAM_STR);
    $query->fetchAll(PDO::FETCH_ASSOC);
    $query->execute();
}
開發者ID:Rwilkins1,項目名稱:Codeup-Web-Exercises,代碼行數:17,代碼來源:national_parks.php

示例14: insertPark

function insertPark($dbc)
{
    $errors = [];
    try {
        $username = Input::getString('username');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $password = Input::getString('password');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $email = Input::getString('email');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $first_name = Input::getNumber('first_name');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $last_name = Input::getString('last_name');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $phone = Input::getString('phone_number');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    if (!empty($errors)) {
        return $errors;
    }
    $userInput = $dbc->prepare('INSERT INTO users (username, password, email, first_name, last_name, phone) VALUES (:username, :password, :email, :first_name, :last_name, :phone)');
    $userInput->bindValue(':username', $username, PDO::PARAM_STR);
    $userInput->bindValue(':password', $password, PDO::PARAM_STR);
    $userInput->bindValue(':email', $email, PDO::PARAM_STR);
    $userInput->bindValue(':first_name', ucfirst($first_name), PDO::PARAM_STR);
    $userInput->bindValue(':last_name', ucfirst($last_name), PDO::PARAM_STR);
    $userInput->bindValue(':phone', $phone, PDO::PARAM_STR);
    $userInput->execute();
    return $errors;
}
開發者ID:adlister-project,項目名稱:Craigslister,代碼行數:46,代碼來源:users.create.php

示例15: insertPark

function insertPark($dbc)
{
    $errors = [];
    try {
        $park = Input::has('park') ? Input::getString('park') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $location = Input::has('location') ? Input::getString('location') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $date_established = Input::has('date_established') ? Input::getDate('date_established') : null;
        $date_established = $date_established->format('Y-m-d');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $area_in_acres = Input::has('area_in_acres') ? Input::getNumber('area_in_acres') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $description = Input::has('description') ? Input::getString('description') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    if (!empty($errors)) {
        return $errors;
    }
    $query = "INSERT INTO national_parks (park, location, date_established, area_in_acres, description) VALUES (:park, :location, :date_established, :area_in_acres, :description)";
    $stmt = $dbc->prepare($query);
    $stmt->bindValue(':park', $park, PDO::PARAM_STR);
    $stmt->bindValue(':location', $location, PDO::PARAM_STR);
    $stmt->bindValue(':date_established', $date_established, PDO::PARAM_STR);
    $stmt->bindValue(':area_in_acres', $area_in_acres, PDO::PARAM_STR);
    $stmt->bindValue(':description', $description, PDO::PARAM_STR);
    $stmt->execute();
    return $errors;
}
開發者ID:Craig240z,項目名稱:CodeUp-Web-Exercises,代碼行數:42,代碼來源:national_parks.php


注:本文中的Input::getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。