therealwesfoster Posted December 10, 2007 Share Posted December 10, 2007 I'm wanting to be able to run a script that will log me in (to 1 of 2 different sites) automatically. I'm having trouble with this.. I have this: index.htm <html> <head> <title>Test Loginner </title> <script src="ccsh.js"></script> </head> <body> <iframe src='http://site.com/login.php' onLoad="setgo()" width='640' height='480' frameborder='0' id='gf' name='gf'></iframe> </body> </html> ccsh.js function setgo() { alert("Start"); try { window.frames["gf"].document.getElementsByTagName("input")[0].value = "USERNAME"; window.frames["gf"].document.getElementsByTagName("input")[1].value = "PASSWORD"; } catch(e) { alert(e); } alert("Input done.. Submitting form now.."); try { window.frames["gf"].document.login.submit(); } catch (e) { alert(e); } alert("Done"); } But I get this error Permission denied to get property HTMLDocument.login And I've learned that you cannot access information from a different domain, but I've done this before. Anyways, my question isn't about the error, the question is how to go about doing this (creating an auto-login with javascript) Thanks, and if this can't be done with javascript, would you mind linking me to some way to do it with php? (Maybe loading the page with the POST vars already sent) Thanks again Link to comment https://forums.phpfreaks.com/topic/81053-automatic-form-login-question/ Share on other sites More sharing options...
phpQuestioner Posted December 11, 2007 Share Posted December 11, 2007 do it like this: <html> <head> <title>Test Loginner </title> <script> function setgo() { window.frames["gf"].document.getElementById("un").value = "USERNAME"; window.frames["gf"].document.getElementById("pw").value = "PASSWORD"; window.frames["gf"].document.form1.submit(); } </script> </head> <body onload="setgo()"> <iframe src='login.php' width='250' height='250' frameborder='0' id='gf' name='gf'></iframe> </body> </html> Link to comment https://forums.phpfreaks.com/topic/81053-automatic-form-login-question/#findComment-411719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.