当前位置: 首页 > 图文教程 > 网络编程 > PHP > 如何在PHP中使用Oracle数据库(4)

PHP
挑战最棒的留言本的源码(三)
php抓即时股票信息
挑战最棒的留言本的源码(四)
使用网络地址转换实现多服务器负载均衡
挑战最棒的留言本的源码(五)
屏蔽浏览器缓存另类方法
PHP脚本数据库功能详解(上)
PHP脚本数据库功能详解(中)
PHP脚本数据库功能详解(下)
一个用mysql_odbc和php写的serach数据库程序
一个简单计数器的源代码
文件上传程序的全部源码
计算2000年01月01日起到指定日的天数
通过文字传递创建的图形按钮
如何在WIN2K下安装PHP4.04
新闻分类录入、显示系统
在字符串中把网址改成超级链接
Php做的端口嗅探器--可以指定网站和端口
不用数据库的多用户文件自由上传投票系统(2)
一个简单的域名注册情况查询程序

如何在PHP中使用Oracle数据库(4)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 105 ::
收藏到网摘: n/a

利用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为表单处理程序