1

I'm fetching some HTML codes from a PHP function and printing it. Something like this:

// the html code
<div><?php echo $this->create_form(); ?></div>

//the php code
function create_form()
{
    return '<form method="POST" id="myform"><input blah blah.../></form>';
}

The problem is that, all elements "inside" the form gets printed, but the form itself is not! For example:

<div><input blah blah.../></div>

If I change "form" with something else like "div", then it gets printed, but whenever I put form element it just doesn't want to be printed!!

Hossain Alhaidari
  • 767
  • 3
  • 11
  • 24

1 Answers1

0

Try this

<div><?php echo create_form(); ?></div>
<?php
//the php code
function create_form()
{
    return '<form method="POST" id="myform"><input class="namefield" type="text"/></form>';
}

?>