It works for iframe because basically your iframe will load that validate.php and the script inside validate.php will be executed.
I am not much familiar with object tag, but I am sure about it that if you want to execute php script you have to load that page again.
Your iframe does the same. Try using AJAX, so that you send request from your current page to validate.php and get the values to your current page. Don't know much I am a newbie.
[sry in advance if it does not work or I din got your problem.