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


PHP redirect_user函数代码示例

本文整理汇总了PHP中redirect_user函数的典型用法代码示例。如果您正苦于以下问题:PHP redirect_user函数的具体用法?PHP redirect_user怎么用?PHP redirect_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: redirectIfLoggedIn

 /**
  * @param string $destination
  * @author Erik Aybar
  */
 public static function redirectIfLoggedIn($destination = '/')
 {
     if (static::checkIfLoggedIn()) {
         $message = "You are already logged in!";
         redirect_user($destination, $message);
     }
 }
开发者ID:erikthedeveloper,项目名称:a-bit-of-fun-with-vanilla-php,代码行数:11,代码来源:AuthMaster.php

示例2: checksessionorkill

function checksessionorkill()
{
    session_start();
    if (!isset($_SESSION['uid'])) {
        // Need the functions:
        require 'includes/login_functions.inc.php';
        redirect_user();
    } else {
        // Cancel the session:
        $_SESSION = array();
        // Clear the variables array.
        session_destroy();
        // Destroy the session itself.
        setcookie('PHPSESSID', '', time() - 3600, '/', '', 0, 0);
        // Destroy the cookie.
    }
}
开发者ID:meslava,项目名称:MDV-Incidents-Project,代码行数:17,代码来源:checksession.php

示例3: createFile

function createFile($filename)
{
    // For security reasons we strip file path and constrain
    // allowable file name
    $file = preg_replace("/[^A-Za-z0-9_\\- ]/", "", basename($filename));
    if (!$file) {
        redirect_user('index.php', http_build_query(array('status_message' => "File {$file} name is invalid")));
    }
    $file .= ".txt";
    $filepath = PATH_TO_FILES . "/{$file}";
    if (file_exists($filepath)) {
        redirect_user('index.php', http_build_query(array('status_message' => "{$file} already exists")));
    } else {
        if (file_put_contents($filepath, "") === false) {
            redirect_user('index.php', http_build_query(array('status_message' => "Couln't create file {$file}")));
        }
        chmod($filepath, 0666);
    }
    return array($file, $filepath);
}
开发者ID:raynaldmo,项目名称:php-education,代码行数:20,代码来源:edit.php

示例4: redirect_user

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
\MyClasses\Auth\AuthMaster::logOut();
redirect_user('/', 'You have been logged out');
开发者ID:erikthedeveloper,项目名称:a-bit-of-fun-with-vanilla-php,代码行数:5,代码来源:logout.php

示例5: redirect_with_message

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
if ($_SERVER['REQUEST_METHOD'] != "POST") {
    redirect_with_message('/users/index.php', "Bad method. Bad user!");
}
$upload_id = $_POST['id'];
$upload = \MyClasses\Models\Upload::getOne($upload_id);
$destroyed = \MyClasses\Models\Upload::destroy($upload_id);
redirect_user('/uploads/index.php', "You killed {$upload['original_filename']}!");
开发者ID:erikthedeveloper,项目名称:a-bit-of-fun-with-vanilla-php,代码行数:10,代码来源:destroy.php

示例6: mysqli_query

    $_SESSION['eventDropDown_errors'] = true;
    $errorText .= "<br/> - Invalid event";
}
//Makes form sticky if any errors
//*itemNameDropDown not sticky because of how number in stock col is being pulled
if ($errorText) {
    //Set variables
    $name = $_POST['name'];
    $changeAmount = $_POST['changeAmount'];
    $eventDropDown = $_POST['eventDropDown'];
    //Display variables back on restock.php to make form sticky
    $_SESSION['name'] = $name;
    $_SESSION['changeAmount'] = $changeAmount;
    $_SESSION['eventDropDown'] = $eventDropDown;
} else {
    //Set variables for query
    $action = $_GET['action'];
    $name = $_GET['name'];
    $currentItem = $_GET['itemName'];
    $currentNumInStock = $_GET['currentNumInStockURL'];
    $amount = $_POST['changeAmount'];
    $updatedNumInStock = $_GET['currentNumInStockURL'] + $_POST['changeAmount'];
    $event = $_GET['event'];
    //Updates inventory list
    $sql = mysqli_query($db, "UPDATE InventoryList SET numInStock='{$updatedNumInStock}' WHERE itemName='{$currentItem}'");
    //Updates change log
    $sql2 = mysqli_query($db, "INSERT INTO ChangeLog (action, name, itemName, numInStock, amount, updatedNumInStock, event, date_time) VALUES ('{$action}', '{$name}', '{$currentItem}', '{$currentNumInStock}', '{$amount}', '{$updatedNumInStock}', '{$event}', NOW())");
}
$_SESSION['form_error_text'] = $errorText;
redirect_user('restock.php');
mysqli_close($db);
开发者ID:apikck,项目名称:inventory_tracking_system,代码行数:31,代码来源:restock-validate.php

示例7: mysqli_query

            $householder = 0;
        }
    } else {
        print '<p style="color: red;">Please submit both a title and an entry.</p>';
        $problem = TRUE;
    }
    if (!$problem) {
        // Define the query.
        $query = "UPDATE users SET first_name='{$f_name}', last_name='{$l_name}', email='{$email}', send_email='{$send_email}', phone_1='{$phone_1}', phone_2='{$phone_2}', pub_type_id='{$pub_type}', servant_type_id='{$serv_type}', public_speaker='{$public_speaker}', chairman='{$chairman}', reader='{$reader}', overseer='{$overseer}', prayer='{$prayer}', bible_high='{$bible_high}', no_1='{$no_1}', no_2='{$no_2}', no_3='{$no_3}', serv_meet='{$serv_meet}', attend='{$attend}', sound_panel='{$sound_panel}', stage='{$stage}', mic='{$mic}', grounds_keeper='{$grounds_keeper}', householder='{$householder}' WHERE user_id={$_POST['id']}";
        $r = mysqli_query($dbc, $query);
        // Execute the query.
        // Report on the result:
        if (mysqli_affected_rows($dbc) == 1 or mysqli_affected_rows($dbc) == 0) {
            require 'include/login_functions.inc.php';
            $user_id = $_POST['id'];
            $page = "display_person.php?user_id={$user_id}";
            redirect_user($page);
        } else {
            print '<p style="color: red;">Could not update the entry because:<br />' . mysqli_error($dbc) . '.</p><p>The query being run was: ' . $query . '</p>';
        }
    }
    // No problem!
} else {
    // No ID set.
    print '<p style="color: red;">This page has been accessed in error.</p>';
}
// End of main IF.
// Close the connection.
include 'db_close.php';
//Include the footer:
include 'include/footer.html';
开发者ID:redshirtjim,项目名称:khlogic,代码行数:31,代码来源:edit_person.php

示例8: mysqli_real_escape_string

            if (strlen($Password1) > 0 && strlen($Password2) > 0 && $Password1 != $Password2) {
                $errors[] = 'Passwords do not match';
            }
        }
        if (empty($errors)) {
            $Email1 = mysqli_real_escape_string($dbc, $Email1);
            //Update the email address
            mysqli_query($dbc, "Call spUpdateUserPassword({$UserID},'{$Password1}');");
            complete_procedure($dbc);
            //Redirect user back to the account settings page
            redirect_user('account_settings.php');
        }
    }
} else {
    //Redirect user back to the account settings page
    redirect_user('account_settings.php');
}
?>
<div class="content">
    <img class="responsive" src="images/wood_image.jpg" alt="wood">
</div>
<div class="contentwidth">
    <div class="row flush">
        <div class="col s7">
            <div class="author roundcorner">
                <h3 class="title">Change Password</h3>
            </div>
            <div class="box_guest author_alt">
                <?php 
if (!empty($errors)) {
    echo '<h1>Error!</h1><p class="error">The following error(s) occurred:<br />';
开发者ID:buseamy,项目名称:GR-JCI,代码行数:31,代码来源:user_update_password.php

示例9: list

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    require 'login_functions.inc.php';
    require 'mysqli_connect.php';
    list($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']);
    if ($check) {
        setcookie('user_id', $data['user_id'], time() + 3600, '/', '', 0, 0);
        setcookie('first_name', $data['first_name'], time() + 3600, '/', '', 0, 0);
        redirect_user('loggedin.php');
    } else {
        $errors = $data;
    }
    mysqli_close($dbc);
}
include 'login_page.inc.php';
开发者ID:alinsilviu,项目名称:ConnectToDatabase,代码行数:16,代码来源:login.php

示例10: elseif

// Written by: Jonathan Sankey on 4/15/2016
// This page removes announcements from the database
// It is accessed through the announcement managment page
require './include_utils/login_functions.php';
//redirect
// Check for a valid announcement ID, through GET or POST:
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    // From announcement_management.php
    $id = $_GET['id'];
} elseif (isset($_POST['id']) && is_numeric($_POST['id'])) {
    // From announcement_management.php
    $id = $_POST['id'];
} else {
    // No valid ID, kill the script.
    echo '<p class="error">Announcement not found.</p>';
    exit;
}
require '../mysqli_connect.php';
// Make the query:
$q = "CALL spRemoveAnnouncement('{$id}')";
if (mysqli_query($dbc, $q)) {
    // If it ran OK.
    redirect_user('manage_announcements.php');
} else {
    // If the query did not run OK.
    echo '<p class="error">The user could not be deleted due to a system error.</p>';
    // Public message.
    echo '<p>' . mysqli_error($dbc) . '</p>';
    // Debugging message.
}
mysqli_close($dbc);
开发者ID:buseamy,项目名称:GR-JCI,代码行数:31,代码来源:remove_announcement.php

示例11: password_verify

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
$rules = ['email' => ["email"], 'password' => ["not_empty"]];
$validator = new \MyClasses\Validation\Validator();
$validator->validate($rules, $_POST);
$validator->redirectWithErrorsIfFailed('/users/login.php');
$user = \MyClasses\Models\User::getOneBy('email', $_POST['email']);
$hashed = $user['encrypted_password'];
$password_is_correct = password_verify($_POST['password'], $hashed);
if ($password_is_correct) {
    \MyClasses\Auth\AuthMaster::logUserInUsingId($user['id']);
    redirect_user('/users/index.php', "Log in success. Congratulations, {$user['first_name']}!");
} else {
    redirect_user('/users/login.php', "Wrong password! Try again...");
}
开发者ID:erikthedeveloper,项目名称:a-bit-of-fun-with-vanilla-php,代码行数:16,代码来源:create.php

示例12: date

if ($errorText) {
    //Set variables
    $name = $_POST['name'];
    $changeAmount = $_POST['changeAmount'];
    $eventDropDown = $_POST['eventDropDown'];
    //Display variables back on request.php to make form sticky
    $_SESSION['name'] = $name;
    $_SESSION['changeAmount'] = $changeAmount;
    $_SESSION['eventDropDown'] = $eventDropDown;
} else {
    //Set variables for query
    $action = $_GET['action'];
    $name = $_GET['name'];
    $currentItem = $_GET['itemName'];
    $currentNumInStock = $_GET['currentNumInStockURL'];
    $amount = $_POST['changeAmount'];
    $updatedNumInStock = $_GET['currentNumInStockURL'] - $_POST['changeAmount'];
    $event = $_GET['event'];
    $date = date('m/d/y h:i:sa');
    //Updates inventory list
    $sql = mysqli_query($db, "UPDATE InventoryList SET numInStock='{$updatedNumInStock}' WHERE itemName='{$currentItem}'");
    //Updates change log
    $sql2 = mysqli_query($db, "INSERT INTO ChangeLog (action, name, itemName, numInStock, amount, updatedNumInStock, event, date_time) VALUES ('{$action}', '{$name}', '{$currentItem}', '{$currentNumInStock}', '{$amount}', '{$updatedNumInStock}', '{$event}', '{$date}')");
}
$_SESSION['form_error_text'] = $errorText;
redirect_user('out-of-stock.php');
mysqli_close($db);
?>

</body>
</html>
开发者ID:apikck,项目名称:inventory_tracking_system,代码行数:31,代码来源:out-validate.php

示例13: session_start

<?php

session_start();
// Check if the form has been submitted:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $errors1 = array();
    require 'login_functions.inc.php';
    require '/Applications/MAMP/mysqli_connect.php';
    if ($_POST['pass'] !== $_POST['pass2']) {
        $errors1[] = "Make sure both passwords are correct!";
    }
    if (empty($_POST['pass']) or empty($_POST["fname"]) or empty($_POST["email"]) or empty($_POST["lname"])) {
        $errors1[] = "All fields must be filled!<br>";
    } else {
        // OK!
        $_SESSION['fname'] = $_POST['fname'];
        $_SESSION['lname'] = $_POST['lname'];
        $_SESSION['email'] = $_POST['email'];
        $_SESSION['pass'] = $_POST['pass'];
        // Redirect:
        redirect_user('registration_handle.php');
    }
    mysqli_close($dbc);
    // Close the database connection.
}
// End of the main submit conditional.
// Create the page:
include 'registration.php';
开发者ID:jonmrod,项目名称:Reservation-System,代码行数:28,代码来源:register.php

示例14: redirect_user

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
$rules = ['first_name' => ['not_empty'], 'last_name' => ['not_empty'], 'email' => ['not_empty'], 'password' => ['not_empty'], 'password_confirmation' => ['not_empty']];
$validator = new \MyClasses\Validation\Validator();
$validator->validate($rules, $_POST);
$validator->redirectWithErrorsIfFailed('/users/new.php');
if ($_POST['password'] != $_POST['password_confirmation']) {
    redirect_user("/users/new.php", "Whoops. Your password confirmation didn't match...");
}
$encrypted_password = password_hash($_POST['password'], PASSWORD_BCRYPT);
$user_create_data = ['first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'encrypted_password' => $encrypted_password];
$users_id = \MyClasses\Models\User::create($user_create_data);
$user = \MyClasses\Models\User::getOne($users_id);
\MyClasses\Auth\AuthMaster::logUserInUsingId($user['id']);
redirect_user('/users/show.php?id=' . $users_id, "Welcome, {$user['first_name']}!");
开发者ID:erikthedeveloper,项目名称:a-bit-of-fun-with-vanilla-php,代码行数:16,代码来源:create.php

示例15: time

            $_SESSION['status'] = $new_user->status;
            $_SESSION['user_type'] = $new_user->user_type;
            $_SESSION['timeout'] = time();
            //Setting user meta information.
            $user_ip = get_client_ip();
            //Function is inside function.php to get ip
            $new_user->set_user_meta($_SESSION['user_id'], 'last_login_time', date("Y-m-d H:i:s"));
            //setting last login time.
            $new_user->set_user_meta($_SESSION['user_id'], 'last_login_ip', $user_ip);
            //setting last login IP.
            $new_user->set_user_meta($_SESSION['user_id'], 'login_attempt', '0');
            //On login success default loign attempt is 0.
            $new_user->set_user_meta($_SESSION['user_id'], 'login_lock', 'No');
            //setting last login time.
            $message = $language['login_success_message'];
            redirect_user($new_user->user_type);
            //Checks authentication and redirect user as per his/her level.
        }
    }
    //setting session variables if user loged in successful!
}
//login process ends here if form submits
$page_title = $language['login_title'];
//You can edit this to change your page title.
$sub_title = "Please login below to access the dashboard.";
require_once 'Includes/header.php';
//adding facebook if activate.
if (get_option('facebook_login') == '1') {
    include 'Includes/add_facebook.php';
    echo '<div id="fb_return_msg"></div>';
}
开发者ID:jackhardcastle,项目名称:wiseoldman,代码行数:31,代码来源:login.php


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