0
我有一個日期選擇器JS,它將日期輸出到inputField中,當我點擊提交時,如何將該值放入變量中,因爲我想將其插入到數據庫中?在變量中存儲值
我會承擔我的INSERT語句中,我會用,INSERT INTO XXXX(ID,日期)VALUES($ _ POST [ '身份證'],ANDTHENSOMETHINGHERE)
<input type="text" size="12" name="datefield" id="inputField" />
<?php $datefield = $_POST['datefield'];
echo $datefield;
?>
以上是我在想什麼?但我知道我錯了
使用隱藏的輸入字段 –
您正在使用[an **過時的**數據庫API](http://stackoverflow.com/q/12859942/19068)並應使用[現代替換](http:// php.net/manual/en/mysqlinfo.api.choosing.php)。你也**易受[SQL注入攻擊](http://bobby-tables.com/)**,現代的API會使[防禦]更容易(http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php)自己從。 – Quentin
Im實際上並沒有使用mysql,我使用postgresql,而且我會尋求進一步的安全性來打擊SQL注入,一旦我有系統工作的基礎知識 – Tom