0

I am trying to repopulate the post value of a text box in php. My html is built dynamically using a string and I am struggling with single and double quotes in the html string while using the php code. Below is my code

function setTestboxValue(){

        $text = "<form action = '' method = 'post'>
                   <input type='text'  name='title' 
                    value='<?php echo isset($_POST['textValue']) ? $_POST['textValue'] : '' ?>' 
                       placeholder = 'book name' />                       
                    <input type = 'submit' value = 'Search' />
                    </form>";
        return $text;
}

I am facing issue with "Possible Syntax error. unexpected variable: $_POST". Would really appreciate if some one can help me with this issue.

Disclaimer: I started working on php since a week, so I am an absolute newbie to php.

NoobGeek
  • 1,661
  • 2
  • 10
  • 7

0 Answers0