php 如何使用oracle数据库创建登录表单?

u4dcyp6a  于 2023-04-04  发布在  PHP
关注(0)|答案(2)|浏览(136)

提前感谢。我有麻烦创建与Oracle数据库登录形式实际上我已经创建了成功的连接,但登录形式连接问题

$conn = oci_connect('hr', 'hr', 'localhost/XE', 'AL32UTF8');
    session_start();

    $myusername = isset($_POST['username']);
    $mypassword = isset($_POST['password']);

    $query = "SELECT * FROM VTP_admin WHERE username='".$myusername."' and password='".$mypassword."'  ";
    $vtpid = oci_parse($conn, $query);

    $result = oci_execute($vtpid);

    $count=oci_num_rows($vtpid);
    echo ($count);

    if($count==1){
        $_SESSION["username"];
        $_SESSION["password"];

        header("localhost/ERP/dashboard.php");
    }
    else{
        echo "Incorrect Username or Password";
    }
wpx232ag

wpx232ag1#

终于完成了这个任务,可能会对一些哥们有帮助。如果你有问题,随时问。

<?php
        session_start();
        global $conn;
        $conn = oci_connect('hr', 'hr', 'localhost/XE', 'AL32UTF8');
        if(isset($_POST['submit'])){
            $user = $_POST['username'];
            $pass = $_POST['password'];
            $s = oci_parse($conn, "select username,password from vtp_admin where username='$user' and password='$pass'");       
            oci_execute($s);
            $row = oci_fetch_all($s, $res);
            if($row){
                    $_SESSION['user']=$user;
                    $_SESSION['time_start_login'] = time();
                    header("location: dashboard.php");
            }else{

                echo "wrong password or username";
            }
        }


     ?>
nmpmafwu

nmpmafwu2#

<?PHP

require_once 'db_connect.php';
session_start();

$user = $_POST['USER_NAME'];
$pass = $_POST['PASSWORD'];
$s = oci_parse($con, "select USER_NAME,PASSWORD from usermst where USER_NAME='$user' and PASSWORD='$pass'");       
oci_execute($s);
$row = oci_fetch_all($s, $RESULT);
$RESULT = array();
if($row){
    $_SESSION['USER_NAME']=$user;
    $_SESSION['time_start_login'] = time();
    $RESULT['message']="Login Successfully"; 
}else{
    //$RESULT['message']="Warning!";
    $RESULT['message']="Username or password is incorrect.";
}
$r = array($RESULT);
echo json_encode($r);

相关问题