怎样在PHP中使用Oracle数据库(4)

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

怎样在PHP中使用Oracle数据库(4)

  2021-03-16 我要评论
想了解怎样在PHP中使用Oracle数据库(4)的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:|怎样|何在|在P|PH|HP|P中|中使|使用|用O|Or|ra|ac|cl|le|e数|数据|据库|库4|4|,下面大家一起来学习吧。
利用OCI向数据表 'email_info' 输入数据

同上,只不过用OCI来写  

相关PHP代码:


if ($submit == "click"){
  // The submit button was clicked!
  // Get the input for fullname and email then store it in the database.
  PutEnv("ORACLE_SID=ORASID");

  $connection = OCILogon ("username","password");
  if ($connection == false){
    echo OCIError($connection)."
";
    exit;
  }

  $query = "insert into email_info values ('$fullname', '$email')";
  $cursor = OCIParse ($connection, $query);
  if ($cursor == false){
    echo OCIError($cursor)."
";
    exit;  
  }

  $result = OCIExecute ($cursor);
  if ($result == false){
    echo OCIError($cursor)."
";
    exit;
  }

  OCICommit ($connection);
  OCILogoff ($connection);
}
else{
  echo '


     <FORM action=insert.php method=post>

    请输入姓名
    <INPUT name=fullname></INPUT>

    请输入 Email 地址
    <INPUT name=email></INPUT>

    <INPUT name=submit type=submit value=click></INPUT>         

    </FORM>

     
  ';
}

?>  


对了,这段脚本必须存为insert.php,因为在调用的页面中指定insert.php为表单处理程序 

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们