标题: 如何在PHP中使用Oracle数据库(4)
France
中校
Rank: 1



UID 44418
精华 2
积分 1776
帖子 858
威望 16
金币 878
热心 0
阅读权限 50
注册 2007-2-18
状态 离线
如何在PHP中使用Oracle数据库(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为表单处理程序

顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-12-2 00:50
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP