Search code examples
phphtmlattributesspace

php code within value attribute for html


I have a html form with a textbox in which i want to pull the name of the person signed in to automatically be filled in the text box when the page loads. below is the code i am using.

<input type="text" autocomplete="off" name="createdby" id="createdby" value= <?= $first_name.' '.$last_name ?> readonly>

the issue is with the php code

   <?= $first_name.' '.$last_name ?>

Because of the space between .' ' . the last name does not show. however when i remove the space both the first name and the last name show but without any spaces. How do i pull both names from the database and have them separated


Solution

  • I believe it needs to look as follows:

    <...value="<?= $first_name.' '.$last_name ?>" readonly>