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


PHP mysql::process_str方法代碼示例

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


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

示例1: mysql

<?php

/**
 * Created by PhpStorm.
 * User: wb.dengxiaohui
 * Date: 2016/3/31
 * Time: 15:20
 */
require_once 'mysql.php';
$db = new mysql("localhost", "root", "asd123", "website");
$salt = "abc123";
$login_username = $db->process_str($_POST["login_username"]);
$login_password = md5($db->process_str($_POST["login_password"]) . $salt);
if ($db) {
    $conn = $db->connect_mysql();
    if ($conn) {
        $sql_login_select = "SELECT password From user WHERE username = '{$login_username}'";
        $select_login_result = $db->query($conn, $sql_login_select);
        $login_row = mysqli_fetch_array($select_login_result, MYSQLI_ASSOC);
        if ($login_row["password"] == $login_password) {
            $lifeTime = 24 * 3600;
            session_set_cookie_params($lifeTime);
            session_start();
            $_SESSION["state"] = 1;
            $_SESSION["username"] = $login_username;
            setcookie(session_name(), session_id(), time() + $lifeTime, "/");
            mysqli_free_result($select_login_result);
            $db->close_db($conn);
            echo "1";
        } else {
            mysqli_free_result($select_login_result);
開發者ID:icenewman,項目名稱:project,代碼行數:31,代碼來源:login.php

示例2: mysql

<?php

/**
 * Created by PhpStorm.
 * User: trinity
 * Date: 2016/2/28
 * Time: 23:03
 */
require_once 'mysql.php';
/**創建數據庫類 **/
$db = new mysql("localhost", "root", "asd123", "website");
/**處理Post數據安全 **/
$salt = "abc123";
$register_username = $db->process_str($_POST["register_username"]);
$register_password = md5($db->process_str($_POST["register_password"]) . $salt);
$register_email = $db->process_str($_POST["register_email"]);
$register_time = $_SERVER['REQUEST_TIME'];
/**開始注冊邏輯 **/
if ($db) {
    $conn = $db->connect_mysql();
    if ($conn) {
        $sql_rigister_select = "SELECT * From user WHERE username = '{$register_username}'";
        $select_rigister_result = $db->query($conn, $sql_rigister_select);
        $row = mysqli_fetch_array($select_rigister_result, MYSQLI_ASSOC);
        if (!$row) {
            $sql_insert = "INSERT INTO  user(username,password,register_time,email) VALUES('{$register_username}','{$register_password}','{$register_time}','{$register_email}')";
            if ($db->query($conn, $sql_insert)) {
                $db->close_db($conn);
                mysqli_free_result($select_rigister_result);
                echo "1";
            }
開發者ID:icenewman,項目名稱:project,代碼行數:31,代碼來源:register.php

示例3: mysql

<?php

/**
 * Created by PhpStorm.
 * User: wb.dengxiaohui
 * Date: 2016/4/8
 * Time: 16:42
 */
require_once 'mysql.php';
/**創建數據庫類 **/
$db = new mysql("localhost", "root", "asd123", "website");
/**處理Post數據安全 **/
$register_username = $db->process_str($_POST["register_username"]);
if ($db) {
    $conn = $db->connect_mysql();
    if ($conn) {
        $sql_rigister_select = "SELECT * From user WHERE username = '{$register_username}'";
        $select_rigister_result = $db->query($conn, $sql_rigister_select);
        $row = mysqli_fetch_array($select_rigister_result, MYSQLI_ASSOC);
        if (!$row) {
            $db->close_db($conn);
            mysqli_free_result($select_rigister_result);
            echo 1;
        } else {
            $db->close_db($conn);
            mysqli_free_result($select_rigister_result);
            echo 0;
        }
    }
}
開發者ID:icenewman,項目名稱:project,代碼行數:30,代碼來源:check_username.php


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