dpizd08264 2018-10-22 07:13
浏览 691
已采纳

如何在QNAP(NAS)上使用PHP重定向

I have a NAS (QNAP) where all my files are hosted and the PHP redirect after a user succefully login is not working how it should. This is the code:

<?php
session_start();

$host = "ip:port";
$user = "root";
$password = "admin";
$db = "segnalazioni";
$conn = mysqli_connect($host, $user, $password, $db);
$errore = "Tentativo di accesso non valido";
$errorNoUsername = "Inserire i dati per loggare";

if(isset($_POST['username'])){
    $userUsername = $_POST['username'];
    $userPassword = $_POST['password'];
    $sql = "SELECT * FROM utenti WHERE username='".$userUsername."' AND password = '".$userPassword."'";
    $result = mysqli_query($conn, $sql);

    if(mysqli_num_rows($result)==1){
        $_SESSION['username'] = $userUsername;
        header('location: main.php');
    } else {
        echo $errore;
    }
} else {
    echo $errorNoUsername;
}
?>

The main.php is in the same folder as this page (called login.php) on my NAS. The connection with the DB is working just fine I tested it with an Echo, only the redirect is not working. The same code on my localmachine (and with localhost instead of ip and port) also work just fine and the page manage to redirect me. The issue should be on the file path (i guess) but i don't know how to properly set it. All files are in this folders in this location:

\192.168.x.x\web\Verifiche

Note: When I try the same code on my local machine using xampp (or wamp or anything like that) it works how it should.

  • 写回答

1条回答 默认 最新

  • douhu2525 2018-10-23 09:47
    关注

    For anyone wondering Ih ad some HTML before the php, in this way the redirect wasn't working. Even if I still need to get why on my local machine it was working fine even if I had HTML before it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化