Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hello this is my php code:
<!DOCTYPE html>
<html>
<body>

$input = $_POST["value"];
function input($input) {
if ($input === TRUE){
echo "Hello";

}
else {
echo "What are you saying?";

};
};
input($input);

?>
<form method="post" action="">
<input type="text" name="value">
<input type="submit">
</form>

</body>
</html>



It should work like this
1. It should take value from me.
2. Verify it with if/else statement.
3. Print the correct statement.

but this what it is doing
only printing and input box bellow it like this:
what are you saying?


and even after entering value it is still saying same thing.

What I have tried:

i tried to solve it but nothing goes right it happens over and over again
Posted
Updated 12-Feb-16 1:28am
v2

I can see a few problems with the code:

  1. There's no semicolon after your last echo statement.
  2. When checking whether $input equals "Hello", you use a single equality sign, but that sign is for assigning a value to a variable. Use two or three equality signs (for the difference between these two, see How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ? - Stack Overflow[^]).
  3. You have a PHP end tag ?>, but you don't have a start tag. Add <?php before you start with the PHP code.
 
Share this answer
 
Comments
Sahilmohile 12-Feb-16 7:29am    
Thank you i have forgoton it
Sergey Alexandrovich Kryukov 12-Feb-16 11:02am    
5ed.
—SA
Quote:
unexpected end of file
is an indication for a missing closing brace.

In your case there is no closing brace for the input() function:

PHP
$input = $_POST['value'];
function input($input) {
    if ($input = "Hello"){
        echo "Hello";
    
    }
    else {
        echo "What are you saying?"
    
    }
// Insert missing brace here
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Feb-16 11:02am    
5ed.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900