php post javascript alert 與 保留資料

在asp.net 錯誤訊息之後會 return 並用js 去alert,

這邊的資訊欄位name在post之後會被保留下來

<?php

$name =  "";

if (isset($_POST['name'])) {  
    $name =   GetPostValue('name');

    echo "<script type='text/javascript'>";
    echo "alert('昨天吃過麥當勞了,今天想吃肯德基');  ";
    echo "</script>";    
}

function GetPostValue($val)
{   
    $resultdata = "";
  if (isset ($_POST[$val])){
        $resultdata=   $_POST[$val];
  }

  $resultdata = trim($resultdata);

  return $resultdata;
}


?>
<html>

<body>

    <form action="<?php $_PHP_SELF ?>" method="POSt">
        Name: <input type="text" name="name"  value="<?php echo $name ;?>" />
        Age: <input type="text" name="age" />
        <input type="submit" />
    </form>

</body>

</html>