Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

PHP Coding Help


ghost's Avatar
0 0

ok this is what i have so far.

<html>
<body> 
<body bgcolor=black>
<br>
<br>
<br>
<br>
<center><font color=white><font size=4> How much dirt is in a hole 6 and a half feet wide, 8 feet deep, and 5 feet long? 

<form action="" method="POST">
Answer: <input type="password" name="password" />
<input type="submit" />
</form> 

<?php
if($password=='none' {
echo "Good job! You got it correct!<br>\n";
}
else {echo "Nice try, but you need to think more.<br>\n";
}
?> 

</font> 
</body>
</html>```


Now what I want it to do is check to see if the password from the form is none. If it is then to echo "Good job! You got it correct!" But for ome reason I cant get it to work. I think it is a problem with my form but I dont know Im new to integradeing PHP with HTML. Not to mention that this is the first PHP code I have ever written. Anyone with a little advice?

Mr_Cheese's Avatar
0 1
<?php
if($password=='none' {
echo "Good job! You got it correct!<br>\n";
}
else {echo "Nice try, but you need to think more.<br>\n";
}
?> ```

try this...

```markup
<?php
if($_POST['password'] = 'none' ) {
echo "Good job! You got it correct!<br>\n";
}
else {
echo "Nice try, but you need to think more.<br>\n";
}
?> ```

ghost's Avatar
0 0

Mr_Cheese wrote:

<?php
if($_POST['password'] = 'none' ) {
echo "Good job! You got it correct!<br>\n";
}
else {
echo "Nice try, but you need to think more.<br>\n";
}
?> ```
No in that if() statement your setting the $_POST['pass'] to the actual password instead of checking it using the ''equal too'' logical operator in C++ ie....
```markup
if($_POST['test'] == "myPass" )  // This would check it ( compare )

is not the same as…

if($_POST['test'] = "myPass" ) // This sets the input to the actuall pass so always says anything they enter is correct.

ghost's Avatar
0 0

And as for to answer the original question you are using the variable $password… but it's not set to nothing? It's blank.. See you have

<?php
if($password=='none' {
echo "Good job! You got it correct!<br>\n";
}
else {echo "Nice try, but you need to think more.<br>\n";
}
?> 

when you need it set to…

<?php
$password = $_POST['password'];
if($password == 'none') {
echo "Good job! You got it correct!<br>\n";
}
else {echo "Nice try, but you need to think more.<br>\n";
}
?> 

You also forgot your closing ')' on the if() statment.