第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用存儲(chǔ)過(guò)程而不是查詢(xún)可以避免 SQL 注入嗎?

使用存儲(chǔ)過(guò)程而不是查詢(xún)可以避免 SQL 注入嗎?

PHP
回首憶惘然 2023-06-30 16:02:32
這里是新手。我一直在研究 SQLSVR 如何利用準(zhǔn)備好的語(yǔ)句來(lái)防止注入,但它們所防止的通常是查詢(xún)本身,而不是諸如存儲(chǔ)過(guò)程之類(lèi)的東西。我當(dāng)前的代碼是否可以避免這種情況?我一直在嘗試?yán)斫膺@里的 PHP 手冊(cè):https://www.php.net/manual/en/function.sqlsrv-query.php但我不太確定這會(huì)是什么樣子,因?yàn)槲艺谑褂么鎯?chǔ)過(guò)程。感謝您花時(shí)間閱讀本文和指導(dǎo)。<?php include('config.php');$mysqli = sqlsrv_connect($serverName, $conn_array);// For error or success messages place the following functions in your functions.php file and include the file here.// The following functions are based on bootstrap classes for error and success message. If you are not using bootstrap you can stylize your own.function alertSuccess($msg){  $alert = "<div class='alert alert-success'>".$msg."</div>";  return $alert;}function alertError($msg){  $alert = "<div class='alert alert-danger'>".$msg."</div>";  return $alert;}function alertInfo($msg){  $alert = "<div class='alert alert-info'>".$msg."</div>";  return $alert;}// Storing Form Inputs$username = ($_POST['username']);$email = ($_POST['email']);$region =($_POST['region']);$password = (!empty($_POST['password']))?$_POST['password']:null;$password2 = (!empty($_POST['confirmpassword']))?$_POST['confirmpassword']:null;if(isset($_POST['register'])) {  // Set "Creating Account" message.   echo alertInfo("Attempting to initiate Account Creation...");  // If username is null then rest of the code will not be executed  if($username == null){    echo alertError("Invalid username!");    header("Location: failed.php");    exit();  }  // If password is not equal then rest of the code will not be executed  if($password != $password2){    echo alertError("Password mismatch");    header("Location: failed.php");    exit();  }  // If username is less than 6 characters long then rest of the code will not be executed  if(strlen($username) < 6){    echo alertError("Username must contain at least 6 characters.");    header("Location: failed.php");    exit();  }  if($region > 2){    echo alertError("Invalid Region.");    header("Location: failed.php");    exit();  }
查看完整描述

1 回答

?
慕森王

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊

挖了一點(diǎn)之后。答案是否定的,如果存儲(chǔ)過(guò)程使用動(dòng)態(tài) SQL,那么它們就不安全。

通過(guò)閱讀手冊(cè)幾千遍,我能夠利用準(zhǔn)備好的陳述。


查看完整回答
反對(duì) 回復(fù) 2023-06-30
  • 1 回答
  • 0 關(guān)注
  • 147 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)