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


PHP functions::get_random_string方法代碼示例

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


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

示例1: end

 // get image file extension
 error_reporting(E_ERROR | E_PARSE);
 $extension = end(explode(".", $_FILES["category_image"]["name"]));
 if ($image_error > 0) {
     $error['category_image'] = " <span class='label label-danger'>Not Uploaded!!</span>";
 } else {
     if (!($image_type == "image/gif" || $image_type == "image/jpeg" || $image_type == "image/jpg" || $image_type == "image/x-png" || $image_type == "image/png" || $image_type == "image/pjpeg") && !in_array($extension, $allowedExts)) {
         $error['category_image'] = " <span class='label label-danger'>Image type must jpg, jpeg, gif, or png!</span>";
     }
 }
 if (!empty($category_name) && empty($error['category_image'])) {
     // create random image file name
     $string = '0123456789';
     $file = preg_replace("/\\s+/", "_", $_FILES['category_image']['name']);
     $function = new functions();
     $menu_image = $function->get_random_string($string, 4) . "-" . date("Y-m-d") . "." . $extension;
     // upload new image
     $upload = move_uploaded_file($_FILES['category_image']['tmp_name'], 'upload/images/' . $menu_image);
     // insert new data to menu table
     $sql_query = "INSERT INTO tbl_category (Category_name, Category_image)\n\t\t\t\t\t\tVALUES(?, ?)";
     $upload_image = 'upload/images/' . $menu_image;
     $stmt = $connect->stmt_init();
     if ($stmt->prepare($sql_query)) {
         // Bind your variables to replace the ?s
         $stmt->bind_param('ss', $category_name, $upload_image);
         // Execute query
         $stmt->execute();
         // store result
         $result = $stmt->store_result();
         $stmt->close();
     }
開發者ID:adhikjoshi,項目名稱:ecom,代碼行數:31,代碼來源:add-category-form.php

示例2: hash

     // Bind your variables to replace the ?s
     $stmt->bind_param('s', $username);
     // Execute query
     $stmt->execute();
     // store result
     $result = $stmt->store_result();
     $stmt->bind_result($data['Password'], $data['Email']);
     $stmt->fetch();
     $num = $stmt->num_rows;
     $stmt->close();
 }
 // if username exist send new password
 if ($num == 1) {
     $email = $data['Email'];
     $string = 'abcdefghijklmnopqrstuvwxyz';
     $password = $function->get_random_string($string, 6);
     $encrypt_password = hash('sha256', $username . $password);
     // store new password to user table
     $sql_query = "UPDATE tbl_user \n\t\t\t\t\t\tSET Password = ? \n\t\t\t\t\t\tWHERE Username = ?";
     $stmt = $connect->stmt_init();
     if ($stmt->prepare($sql_query)) {
         // Bind your variables to replace the ?s
         $stmt->bind_param('ss', $encrypt_password, $username);
         // Execute query
         $stmt->execute();
         // store result
         $reset_result = $stmt->store_result();
         $stmt->close();
     }
     // send new password to user email
     if ($reset_result) {
開發者ID:adhikjoshi,項目名稱:ecom,代碼行數:31,代碼來源:forget-password-form.php


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