I am new to php, learning php from w3 schools. I am making a simple form to accept and display the name and email address of the user. I want to accept and display the email and name using a single php file rather than making two different files, one html file to accept and one php file to display. The question is can I use html tags inside the php block? I have tried but i does not work-
<html>
<body>
if(isset($_POST["email"],$_POST["name"]))
{
echo "your name is".$_POST["name"]."<br>";
echo "your email address is".$_POST["email"]."<br>";
}
else
{
<form action="form.php" method="post">
Name:<input type="text" name="name">
Email:<input type="text" name="email">
<input type="submit">
</form>
}
?>
</body>
</html>
This code gives an syntax error and the form tag does not get color coded. What is wrong in this? Please help I have seen a similar question on this site but there were answers but they were not useful as I cannot close he php block as I need the if else statements which cannot be used in the html block. Further I am making a form which needs php commands to print.