How can I prevent SQL injections in the PHP oci extension?

拟墨画扇 提交于 2019-12-11 02:51:47

问题


I see a lot of questions on here regarding MySQL, but what about when using OCI?

Is the simplest method to create a function that strips all characters from a string except for A-Z 0-9 and run the $_POST through it?

May I have an example?

Code

<?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);

}

?>

来源:https://stackoverflow.com/questions/23630809/how-can-i-prevent-sql-injections-in-the-php-oci-extension

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!