HTML / PHP: Wie kann ich ein Passwort bei Anzeige zensieren?
Hi, ich habe ein Passwort in $passwort eingespeichert und will, dass wenn ich es anzeigen lasse, es zensiert ist und nebendran ein Knopf ist, um es sichtbar zu machen. Kann mir jemand dabei helfen?
2 Antworten
<input id="pass" name="pass" type="password" value="<?php echo $passwort; ?>">
<button onclick="show()">show</button>
<script>
function show() {
document.getElementById("pass").type="text";
}
</script>
alexthenr14
08.02.2023, 20:04
@Liam2897
du kannst nicht PHP mit JavaScript verbinden!!!!!!!!!!!!!!!!!!!!
<input id="pass" name="pass" type="password" value="<?php echo $passwort; ?>">
<button onclick="show()">show</button>
<script>
function show() {
document.getElementById("pass").type="text";
}
</script>
<?php
if(isset($_POST['pass'])) {
$passwort = $_POST['pass'];
echo "Das eingegebene Passwort lautet: " . $passwort;
} else {
echo "Es wurde kein Passwort eingegeben.";
}
?>
<input type="text" id="myInput">
<input type="button" value="Ändere Input-Typ" onclick="changeInputType()">
<script>
function changeInputType() {
const inputElement = document.getElementById("myInput");
if (inputElement.type === "text") {
inputElement.type = "password";
} else {
inputElement.type = "text";
}
}
</script>
<?php
$passwort = 1234
<input id="pass" name="pass" type="password" value="<?php echo $passwort; ?>">
<button onclick="show()">show</button>
<script>
function show() {
document.getElementById("pass").type="text";
}
?>
was muss ich noch machen ?