原因未知,登录表单无法在Safari中工作(从5.1.x到最新版本)。尽管与其他浏览器一起工作。Safari:表单提交
的完整代码(网页是的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> </td>
<td><button>Login</button></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Core::Authenticate
是,如果凭证匹配,返回true的功能。
require_once.php
包含其他所需文件,如配置文件,DB库等
domin_path
是脚本的绝对路径,在全球范围内定义。
我不认为这是服务器端的错误,因为其他浏览器(Chrome,IE,Firefox)的工作。
我怀疑这是由于<button>
标签,但是当我抬头的文件(从Safari HTML Reference和MDN),无type
属性按钮标签,因为Safari浏览器1.0的支持。因此,我试图将其更改为<input type="submit" value="Login" />
,但Safari仍拒绝工作(重定向到没有任何消息的同一页面)。
我还看到了什么?
注意:没有在Safari中检测/显示的问题。没有控制台消息。该页面也通过了W3C HTML验证。
请定义“不工作”。这是否意味着按钮不提交表单? – deceze 2013-02-28 08:32:52
它提交表单,但重定向到同一页面,没有任何错误消息 – Raptor 2013-02-28 08:35:42
这个页面是index.php页面吗? – George 2013-02-28 08:39:04