my task is: we have two textboxes and checkbox on the form , we enter login and password in two textbox, then we write this information into .txt file. Next time when we enter login and checkbox is checked ( checkbox is function "remember me") we must read from this file password's user and automatically put it to password's textbox. For example: first time we enter John 3456 , Michael 4321 (writes in file) . Next time is checkbox "Remember me" is checked and we enter John, pass automatically insert 3456 . Here my code: PHP
<?php
if(isset($_POST['field1']) && isset($_POST['field2'])) {
$data = $_POST['field1'] . '-' . $_POST['field2'] . "\n";
$ret = file_put_contents('mydata.txt', $data, FILE_APPEND);
header("Location: http://rememberme/main.html");
/*if($ret === false) {
die('There was an error writing this file');
}
}
else {
die('no post data to process');*/
}
if(isset($_POST['test'])) {
??what next??
}
?>
And my form:
<html>
<head>
</head>
<body>
<form action="script.php" method="POST">
<input name="field1" type="text" />
<input name="field2" type="password" />
<input type="submit" name="submit" value="Save Data">
<input type="checkbox" name="test" value="accepted">
</form>
</body>
</html>
So , what next I must to do?? Thanks
Aucun commentaire:
Enregistrer un commentaire