Post + form + action + results on the same page
I'm trying to put on a post a custom form and, on the same page I'd like to visualize the results of an action on the form.
But I'm missing the basics.
Essentially I'd like to do something like this. Is it possible?
?php
if(isset($_REQUEST['submit_btn']))
{
echo "div";
$name = $_POST["names"];
echo "/div";
}
?
form action="" method="POST"
input type="text" name="names" id="names"
input type="submit" value="submit" name="submit_btn"
/form
ADDITION (after the answer from Tejas gajjar):
Thank for the answer. Actually I don't need to interact with the DB so I removed some of the suggested lines.
If I use this:
Question: Do you know why it renders like this?:
ADDITION (after the comment from Milo):
OK it worked. I was even able to access the form field.
form action="" method="POST"
input type="text" name="names" id="names"
input type="submit" value="submit" name="submit_btn"
/form
[insert_php]
if(isset($_REQUEST['submit_btn']))
{
echo "div";
$name = $_POST["names"];
echo "/br";
echo "ANSWER:/br/br", $name;
echo "/div";
}
[/insert_php]