HTML / PHP: Wie kann ich ein Passwort bei Anzeige zensieren?

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>

Liam2897 
Beitragsersteller
 08.02.2023, 19:53

<?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 ?

0
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.";
}
?>
1
<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>