Forum Moderators: open
<form method="post">
<input type="hidden" name="username" value="random1">
<input type="hidden" name="password" value="random2">
Username: <input type="text" name="random1" value=""><br />
Password: <input type="password" name="random2" value="">
</form>
Where "random1" and "random2" are random names generated, you can use in combination with unix time.
Second page ( PHP output ) :
<?php
if ( isset($_POST['username'], $_POST['password']) &&
isset($_POST[$_POST['username']], $_POST[$_POST['password']]) ) {
echo ''.
'Username: '.$_POST[$_POST['username']].'<br />'.
'Password: '.$_POST[$_POST['password']];
}
?>
With this simple solution you will don't worry about autocomplete anymore in any browser.
Complete PHP example for testing:
--- PHP Begin -------------------------------
<?php
if ( isset($_POST['username'], $_POST['password']) &&
isset($_POST[$_POST['username']], $_POST[$_POST['password']]) ) {
echo ''.
'Username: '.$_POST[$_POST['username']].'<br />'.
'Password: '.$_POST[$_POST['password']];
exit;
} else {
$u = 'u'.time().rand(0, 100);
$p = 'p'.time().rand(0, 100);
}
?>
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
</head>
<body>
<form method="post" action="?p">
<input type="hidden" name="username" value="<?php echo $u; ?>">
<input type="hidden" name="password" value="<?php echo $p; ?>">
Username: <input type="text" name="<?php echo $u; ?>" value=""><br />
Password: <input type="password" name="<?php echo $p; ?>" value=""><br />
<input type="submit">
</form>
</body>
</html>
--- PHP End -------------------------------
[edited by: eXpertPHP at 4:32 pm (utc) on July 3, 2008]
set like this:
<form method="post" action="" autocomplete="off">
I'm not exactly sure where you use the solution presented above...