How to input PHP into HTML placeholder?
<p>I'm trying to make it so a cookie saves the users name and then puts it in the HTML placeholder next time they visit. What's the most efficient way of doing this?</p>

<p>I searched the other threads and tried using 'include' and putting $name in the input placeholder, but it ends up giving me errors because txtName and txtAge are undefined. I'm unsure how to reorganize my code to get it working.</p>

<p>PHP&amp;HTML Doc#1:
    

<pre><code>    $doc = "&lt;!DOCTYPE html&gt;
        &lt;html lang='en'&gt;
        SOME HTML........
        &lt;input type='text' name='txtName' id='txtName' placeholder='$name'&gt;
        SOME HTML........
    &lt;/html&gt;";

echo $doc;
</code></pre>

<p>PHP/Doc#2:</p>

<pre><code>&lt;?php 

    $name = $_POST["txtName"];
    $age = $_POST["txtAge"];
    $k = $_POST['radRaceLength'];


    ///check if cookie exists
    if ( isset($_COOKIE["nameData"]) ){
        $name = $_COOKIE["nameData"];
    }
    else{
        $name = $name;
    }
    if ( isset($_COOKIE["ageData"]) ){
        $age = $_COOKIE["ageData"];
    }
    else{
        $age = $age;
    }
    setcookie("nameData", $name, time() + 3600, "/");
    setcookie("ageData", $age, time() + 3600, "/");

    $fiveK = 10 + ($age / 2); 
    $tenK = 18 + ($age / 3);
    $member = isset($_POST["chkMember"]) ? $fiveK = $fiveK - 5 AND $tenK = $tenK - 5: $member = NULL;

    if ( !$name AND $age &lt;= 21 )
        echo "Please provide a name and valid age";
    else

        echo $name.', you are registered for the '.$k.' race. Your fee is: ';
        echo ( ($_POST["radRaceLength"] == "5K")? "$fiveK":"$tenK" );



?&gt;
</code></pre>