1
我有一些代碼用於打印每個變量,我通過一個窗體傳遞給處理腳本。對於每個帖子變量插入mysql數據庫
我有一個數據庫具有相同的命名約定,我想發佈每個變量。我知道這有一些安全含義,但考慮到我必須通過的變量數量,它是最實際的解決方案。
這是我當前的腳本..
<?php
printArray($_POST);
function printArray($array){
foreach ($array as $key => $value){
echo "$key => $value" . "<br>";
if(is_array($value)){ //If $value is an array, print it as well!
printArray($value);
}
}
}
?>
我知道我可以做這樣的事情..
<?php
printArray($_POST);
$sql = "INSERT INTO (applications) VALUES (";
function printArray($array){
foreach ($array as $key => $value){
$sql .= "'" . $key."'";
echo $sql;
if(is_array($value)){ //If $value is an array, print it as well!
printArray($value);
}
}
}
?>
是否有更簡單的方法來做到這一點?
$ _ POST是不安全的,使用$ =後filter_input_array(INPUT_POST,適當的過濾器在這裏看到PHP手冊); – Chris 2015-04-01 23:57:54