Codice PHP:
<?php

$nrand
=rand(100,999);

echo<<<OUTPUT
<form name="form" method="post" action='paginadiinvio.html'>
Username: <input type="text" name="username" readonly="readonly" id="username" />


Nome: <input type="text" name="nome" id="nome" onchange="document.getElementById('username').value=this.value+document.getElementById('cognome').value+
$nrand;"/>


Cognome: <input type="text" name="cognome" id="cognome" onchange="document.getElementById('username').value=document.getElementById('nome').value+this.value+
$nrand;" />


<input type="submit" value="invia" /> </form>

OUTPUT;

?>

Prova questo, non ho avuto modo di provarlo, dimmi se può andare