0

I have an input field with name:"fsearch" from which i want to get inputted data. I am using if(issetwith $_POST properties but php cannot detect it,it is returning false.Here is my code

<!----------------------------------------------------------------
                              HTML
----------------------------------------------------------------->
<form method="POST">
<p>Търсене на храни: <input type="text" name="fsearch" id="food_search"></p>
</form>
<!----------------------------------------------------------------
                             PHP
----------------------------------------------------------------->
<?php
if(isset($_POST['fsearch']) && !empty($_POST['fsearch'])) {
echo "True!";
}
else{
echo "false";
}
?>

I don't know where i have a mistake :/

EDIT:I am using it for google like instant search,i don't really need submit button.It must compare inputted information with database ROW and if there are letters matched,to print it out.

4
  • 3
    do you submit the form? Commented Jan 15, 2017 at 19:22
  • Sorry i don't know what you mean.I need Sumbit button? I am pretty new and still stupid,so if you can please explain. <3 Commented Jan 15, 2017 at 19:25
  • yes add a submit button into the form also in the declaration you should really use action="somepage.php" even when you are submitting to the same page. Commented Jan 15, 2017 at 19:27
  • It is still returning false(i deleted my cache also);/ Commented Jan 15, 2017 at 19:45

1 Answer 1

1

You need to correct your form, here is how.

    <form method="POST" action='myphpfile.php'>
    <p>Търсене на храни: <input type="text" name="fsearch" id="food_search">      </p>
    <input type="submit" value="Submit">
    </form>
Sign up to request clarification or add additional context in comments.

3 Comments

I copied your example and pasted my page in it,but it is still returning false..(also deleted cache)
I just tested it and it works fine. Please make sure to change the value 'myphpfile.php', to the actual name of the file you are using to post your form. If you are posting to the same file that your form is, use action="<?php echo $PHP_SELF;?>
Well the bad is mine i wasn't really specific what i want .The code works,but i cannot really explain what i want,thats why i will mark it as an answer,it might help somebody.And when i feel ready with my question will ask again,and be more specific.Thanks for answer mate <3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.