本文整理匯總了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);
示例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";
}
示例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;
}
}
}