禁用文本输入历史记录

时间:2011-09-24 15:55:34

标签: php

  

可能重复:
  How do you disable browser Autocomplete on web form field / input tag?

我正在构建一个接受信用卡数据的应用程序。我想确保浏览器不记得键入信用卡号的文本输入中的内容。我尝试传递以下标题:

header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

然而,一旦页面重新加载,我可以点击信用卡文本输入字段,它会让我看到我之前写的内容。我该如何防止这种情况?

2 个答案:

答案 0 :(得分:101)

<input type="text" autocomplete="off"/>

应该有效。或者,使用:

<form autocomplete="off" … >

表示整个表单(请参阅this related question)。

答案 1 :(得分:6)

<input type="text" autocomplete="off" />