That will not always work, sorry, but sometimes login scripts contain a cookied verification...
Also, if the form DOES NOT contain ('action='someurl') then it wont work, because the login is POsting to the same page.
required *
<form action='someurl' method='post or get'>
if action isn't there, you can try: (in your webpage still paste the same script)
Now log in to your facebook (for example) and when you hit login... read the directory name (e.g login.php). if it stays on the same page, its probably settable that in your action could be 'http://facebook.com/login.php'.