如何防止PHP oci扩展中的SQL注入?

时间:2014-05-13 12:06:27

标签: php oci

我在这里看到很多关于MySQL的问题,但是在使用OCI时呢?

最简单的方法是创建一个函数来除去A-Z 0-9以外的字符串中的所有字符并通过它运行$_POST吗?

我可以举个例子吗?

代码

<?php

include("core/connection.php");

if (!empty($_POST)) {

  $stid = oci_parse($conn, "SELECT CustomerNo FROM Customers WHERE Username = '" . $_POST['username'] . "' AND Password = '" . $_POST['password'] . "'");
  oci_execute($stid);

  $count = oci_fetch_all($stid, $res);
  if ($count > 0) { 

    session_start();
    $row = oci_fetch_array($stid, OCI_NUM);
    $_SESSION['account'] = $row['0'];
    header("Location: index.php"); 

  }

  oci_free_statement($stid);
  oci_close($conn);

}

?>

0 个答案:

没有答案
相关问题