1。URLアドレスの注入:
// url違法なSQL文字var surl = location.search.tolowercase(); var squery = surl.substring(surl.indexof( "=")+1); Re =/select | update | delete | truncate | join | join | union | exec | insert | drop | count | '| "|; | | | <|%/i; if(re.test(squery)){alert("違法文字を入力しないでください "); href = surl.replace(squery、");};}2。注入を防ぐためにテキストボックスを入力してください:
/sqlインジェクション2の防止Antisqlvalid(ofield)3 {4 re = /select | update | delete | count | count | '| "|" | = |; | | <|% /I; 9 ofield.classname = "errinfo"; 10 ofield.focus(); 11 falseを返します。 12}次のメソッドを入力テキストボックスに追加します。
txtname.attributes.add( "onblur"、 "antisqlvalid(this)"); // sqlスクリプトインジェクションを防ぎます
SQLインジェクションを防ぐための2つの簡単なJSコードを共有する上記の記事は、私があなたと共有するすべてのコンテンツです。参照を提供できることを願っています。wulin.comをもっとサポートできることを願っています。