Jump to content

Automatic Form Login question...


therealwesfoster

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.