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

时间:2017-11-15 10:40:24

标签: php oracle

提前致谢。 我在使用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";
    }

2 个答案:

答案 0 :(得分:0)

最后完成这项任务可能会对一些好友有所帮助。如果您有任何问题,请随时提出。

 <?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";
            }
        }



     ?>

答案 1 :(得分:-1)

<?php
if (isset($_GET['Pdelete'])) {
    $delid = sanitize($_GET['Pdelete']);
    $db->query("DELETE FROM products WHERE ID = $delid");
    header('Location: Archived.php');
}
?>


<a href="Archived.php?Pdelete=<?= $product['ID']; ?>" class="btn btn-xs btn-default"><i class="far fa-trash-alt"></i></a>