I have this code, and I want to send a message when the password = hello. But the page shows immediadly the text: 'good pass' and 'bad pass'
What's wrong with this code?
<body>
<?php
if(isset($_POST['submit']))
{
$wachtwoord = ($_POST['wachtwoord']);
if ($wachtwoord = "hello")
{
?><h1>Good pass</h1><?php;
}
else
if($wachtwoord != "hello")
{
?><h1>Wrong pass.</h1><?php;
}
}
else
{
?>
<center>
<br><br><br><br>
<table>
<tr><td>Hello User, <br><br><hr>
<b><a href="link0/">DirectAdmin</a><br><br>
<a href="link1/">PHPMyAdmin</a></b><br>
<form action="" method="POST">
<input name="wachtwoord" type="text" /><input type="submit" name="submit" value="Go" /></td></tr>
</form>
</table>
<br><br>
</center>
<?php
}
?>
</body>
You're presently assigning if ($wachtwoord = "hello") with a single equal sign =
Use two like this: == then do if ($wachtwoord == "hello") in order to compare.
Assignment operator => =
Comparison operator => ==
You are assigning the value hello to the variable $wachtwoord in this code
if ($wachtwoord = "hello")
^
{
?><h1>Good pass</h1><?php;
}
You have to use comparison operator(==) instead of using assignment operator (=). Change it to
if ($wachtwoord == "hello")
^
{
?><h1>Good pass</h1><?php;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With