AutoPost Form

Help needed: I would like to create an auto post form or something that can do the same with a form so that my username and password are remembered and automatically logged in. (This can either be set as a favourite or ie document on the desktop). I currently have it working with a button but i would like to bypass the clicking of the button, where the browser window that opens will automatically direct me to the page in question.

Code used so far which allows a login by clicking a button but i would like script to automatically load the username and password without clicking a button.

<HEAD>
</HEAD>

<BODY>

<FORM name=LoginForm action=--the URL goes in here-- method=post>
<INPUT type=hidden value=ll.login name=func>
<INPUT type=hidden name=CurrentClientTime>
<INPUT
type=hidden
value=
name=NextURL>
<INPUT
class=valueEditable
type=hidden
id=Username
size=40
name=Username
value="">
<INPUT class=valueEditable
type=hidden
id=Password
size=40
name=Password
value="">

<INPUT class=saveButton type=submit value=Log-in border=5>
</FORM>

</BODY>

I am looking to create this using HTML and Javascript. It would appear that the page does not generate a cookie, is there a way round this?

Does anyone have example code and could explain how to do this. I imagine it should not be that hard but being a novice does not help.

Thanks in advance for any help.
[2028 byte] By [Big Red] at [2007-11-19 12:33:24]
# 1 Re: AutoPost Form
What language are you programming in? If you are using PHP, you can check for a cookie, and if it exists, send the username and password to check if it is in the database (authenticate the cookie).

If you are using solely HTML and Javascript, check for the cookie, and if it exists, change the values of the text boxes, and access the form and use the submit method (document.forms['formName'].submit()).

To help out more, I'd need some more information.
Dr. Script at 2007-11-8 0:21:24 >
# 2 Re: AutoPost Form
I could help you to make it generate a cookie, set the values of the 2 fields, and auto-submit, but ... I'll only help via the forums. I do not respond the email requests, especially when the other end doesn't permit emails to be sent online.
Dr. Script at 2007-11-8 0:22:34 >
# 3 Re: AutoPost Form
Any help would be greatfully received.

Thanks
Big Red at 2007-11-8 0:23:28 >
# 4 Re: AutoPost Form
Ok, what we are going to have to do is store a cookie of the username and password when submitted. Then, on every entry to the login page, you'd check for a cookie. However, ..., the issue with this is ... it would work better if you were using PHP.

I could possibly write something up that could work in JavaScript, but first I'd need 2 questions answered:

- Can you use PHP?
- How do you authenticate the username and password?
Dr. Script at 2007-11-8 0:24:33 >
# 5 Re: AutoPost Form
If i understood correctly, you don;t need any cookies for this one...

First thing, you put the values in the source of the document. (the username and password)
Create a function that submits the form like :
function SubmitForm() {
Form1.username.value = "gilly914";
Form1.password.value = "password";
Form1.submit();
}
And then just add to your BODY tag, an onload() function that triggers the function like :
<body onload="javascript:SubmitForm();">

I hope this helped...
gilly914 at 2007-11-8 0:25:38 >
# 6 Re: AutoPost Form
If that is a solution, I misunderstood the question. I interpretted an online form for other users. If it is just his, why indeed, it could easily be hardcoded in.

Of course, take out the javascript: pseudo-protocol. It doesn't need to be included in event handlers.
Dr. Script at 2007-11-8 0:26:39 >
# 7 Re: AutoPost Form
It looks like you are just wanting to store a url to take you straigh into an application, from a developers point of view this is very insecure, but depending on what sort of application it is you maybe be able to do this to skip the form part all together.

Create a favourite manually and store the URL that the form submits to as "http://www.server.com/authentication.asp?username=gilly914&password=password"

This will rely on a few things though, one a lack of security on the site you are trying to log into, eg if they are checking that information is submitted by a post, it wont work. As well as any referrer information they may be checking to make sure that your login come from an authorised location. But it may help you.

The problem i see, is security is there for a reason and doing this removes it. If you machine is every stolen, people may have access to any information stored within the logged in area. I know for sure that this method will not work on my server.
Vanny at 2007-11-8 0:27:32 >
# 8 Re: AutoPost Form
In the first post, "Big Red" write the form he built, and it is submitted through post..

This means, adding the variables manually to the URL will probably not work...
gilly914 at 2007-11-8 0:28:41 >
# 9 Re: AutoPost Form
True and I did take the into consideration, however it does depend on the level of security being applied server side, and anyone asking this question takes security to lightly in my books.
Vanny at 2007-11-8 0:29:38 >
# 10 Re: AutoPost Form
Thanks for your help guys, I got it working yesterday. As for the valid point vinny made about security and taking it lightly.

I am more than sure amongst the people that answered me use sites all the time that to be honest dont really matter if you have security on the username and password e.g. Code Guru, if I used this site a lot and it did not store a cookie I would have to log in all the time and if I was doing that 10 times daily, a lot of time is wasted.

But I take on board your comment and however I have noticed your policing of security allowed you to show me how create the code then evidentally say anyone asking this question takes security far to lightly. Hmm

I hope you guys save yourself time in the day by doing the same, and Vinny good luck with your book on "how to handle fraud prevention".

Regards

Big Red
Big Red at 2007-11-8 0:30:43 >