Safari:表单提交

Rap*_*tor 1 html safari

由于原因不明,登录表单无法在Safari中运行(从5.1.x到最新版本).但与其他浏览器一起使用.

完整代码(页面是index.php)

<?php
ini_set('display_errors', '1');
$err = '';
if(isset($_POST['action']) && $_POST['action'] == 'login') {
    require_once('require_once.php');
    $ans = Core::Authenticate($_POST['txt_user'], $_POST['txt_pass']);
    if($ans) {
        session_set_cookie_params(3600, domain_path);
        session_start();
        $_SESSION['login_key'] = 'A COMPLEX LOGIC';
        header('Location: console.php');
        exit;
    } else {
        $err = 'Invalid Username / Password';
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Login</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
    <div id="login_wrapper">
        <form action="index.php" method="post">
        <input type="hidden" name="action" value="login" />
        <h1>Welcome</h1>
    <?php
    if($err != '') {
        echo '<p>Error: ' . $err . '</p>' . PHP_EOL;
    }
    ?>
                <table class="tbl_login">
            <tr>
                <td>Username</td>
                <td><input type="text" name="txt_user" /></td>
            </tr>
            <tr>
                <td>Password</td>
                <td><input type="password" name="txt_pass" /></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td><button>Login</button></td>
            </tr>
        </table>
        </form>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Core::Authenticate 是一个函数,如果凭据匹配则返回true.

require_once.php 包含其他必需的文件,如配置文件,数据库库等.

domin_path 是脚本的绝对路径,在全局范围内定义.

我不认为这是服务器端错误,因为其他浏览器(Chrome,IE,Firefox)可以工作.

我怀疑这是由于<button>标记,但是当我查找文档时(来自Safari HTML ReferenceMDN),type自Safari 1.0以来,支持不带属性的按钮标记.因此我尝试将其更改为<input type="submit" value="Login" />,但仍然,Safari拒绝工作(重定向到同一页面,没有任何消息).

还有什么我看错了?

注意:Safari中未检测到/显示任何问题.也没有控制台消息.该页面也通过了W3C HTML验证.

Rap*_*tor 5

最后找出了Safari无法提交表单的原因.

不知怎的,domain_path没有正确设置.它不包含领先/.更正域路径后,函数session_set_cookie_params()正常工作.

但为什么其他浏览器工作正常?