gpt4 book ai didi

java - 连接到 oracle 服务器以获取 login.php

转载 作者:行者123 更新时间:2023-12-02 10:54:41 27 4
gpt4 key购买 nike

我正在尝试使用uni中的is连接到oracle服务器。我认为它确实连接,但是我无法从表中选择来检查登录凭据是否相同才能登录。我也尝试过其他方法,但这是迄今为止我最接近的方法。问题出在 oci_bin 部分,它显示错误,但我不知道有任何其他方法来解决这个问题。

<?php
session_start();

if(!isset($_POST['username']) || !isset($_POST['password'])) {
header("Location: ../session.php");
}

putenv("ORACLE_SID=teaching");
if ($Connection = oci_connect("w4e09", "melih312")) {
print "Connection OK \n";}

if(isset($_SESSION['loggedin'])) header("Location: ../secret.php");

$Statement = oci_parse($Connection, 'select *
from Company
where address = :un_bv
and email = :pw_bv' );
Oci_bind_by_name($s, ":un_bv", $_POST['username']);
Oci_bind_by_name($s, ":pw_bv", $_POST['password']);
oci_execute($s);
$r = oci_fetch_array($s, OCI_ASSOC);
}
if ($r) {
$_SESSION['loggedin']=TRUE; $_SESSION['username']="admin";
}
else {
// No rows matched so login failed
login_form('Login failed. Valid usernames/passwords ' .
'are "chris/tiger" and "alison/red"');
}
header("Location: secret.php");
?>

最佳答案

oci_bind_by_nameoci_executeoci_fetch_array 必须使用 oci_parse 返回的资源。在您的情况下,这将是 $Statement 变量:

$Statement = oci_parse(
$Connection,
'select * from Company where address = :un_bv and email = :pw_bv'
);

oci_bind_by_name($Statement, ":un_bv", $_POST['username']);
oci_bind_by_name($Statement, ":pw_bv", $_POST['password']);

oci_execute($Statement);
$r = oci_fetch_array($Statement, OCI_ASSOC);

查看文档:

http://php.net/manual/en/function.oci-connect.php

http://php.net/manual/en/function.oci-parse.php

关于java - 连接到 oracle 服务器以获取 login.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51863357/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com