亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么 htmlentities 在我的 Autosdb 代碼中不起作用?

為什么 htmlentities 在我的 Autosdb 代碼中不起作用?

Go
三國紛爭 2023-08-21 16:26:25
我想做的就是將 html 注入轉義到我的輸入文本框中。我沒有正確使用 htmlentities 嗎?代碼:<?php   require_once "pdo.php";   // Demand a GET parameter   if ( ! isset($_GET['name']) || strlen($_GET['name']) < 1  ) {       die('Name parameter missing');   } else {       $username = $_GET['name'];   }   // If the user requested logout go back to index.php   if ( isset($_POST['logout']) ) {       header('Location: index.php');       return;   }   $year = isset($_POST['year']) ? $_POST['year'] : '';   $mileage = isset($_POST['mileage']) ? $_POST['mileage'] : '';   $make = isset($_POST['make']) ? $_POST['make'] : '';   $failure = false;   $success = false;   if ( isset($_POST['make']) && isset($_POST['year'])         && isset($_POST['mileage'])) {       //$year = $_POST['year'];       //$mileage = $_POST['mileage'];       //$make = $_POST['make'];       if ( strlen($make) < 1){           $failure = "Make is Required";       } else {                  if (is_numeric($year) and is_numeric($mileage) ){               error_log("year is a number ".$_POST['year']);                       error_log("Mileage is a number ".$_POST['mileage']);               $sql = "INSERT INTO autos (make, year, mileage)                  VALUES (:make, :year, :mileage)";               $stmt = $pdo->prepare($sql);               $stmt->execute(array(               ':make' => $make,               ':year' => $year,               ':mileage' => $mileage));               $success = "Record Inserted";                 } else {               $failure = "Mileage and Year must be numeric";               error_log("year or mileage is not a number year=".$_POST['year']);                       error_log("Mileage or year is not a number mileage=".$_POST['mileage']);           }       }   }輸出不會轉義見截圖:
查看完整描述

1 回答

?
江戶川亂折騰

TA貢獻1851條經驗 獲得超5個贊

將 htmlspecialchars 添加到 (make) 給了我我正在尋找的結果。感謝任何人嘗試幫助我。



查看完整回答
反對 回復 2023-08-21
  • 1 回答
  • 0 關注
  • 191 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號