Click to See Complete Forum and Search --> : [RESOLVED] Javascript Login


aaronking
September 22nd, 2008, 09:45 PM
Hello,

I am trying to create login form

however I want to make it when the user clicks the login button I want what ever the user types in as the username and password to appear in the URL.

For Example:
Login page = login.htm
username = username
password = password

and I want it to look like this in the URL address:
login.htm?user=username&pass=password

I have done the following code so far:


<form action="login.htm" method=POST>

Username <input type=text name=user size="20"><br />
Password <input type=password name=pass size="20">
<input type=submit value="Login"><p>
</form>


and now im stack, I don't know how to put the username and password in the url as well.

can anyone help me out?

Thanks

mmetzger
September 23rd, 2008, 12:22 AM
You really don't want to do this - putting a username / password into a URL doesn't provide any sort of security and can cause you issues with caching servers (even transparent ones), log files, etc.

That said, if you must do this, change your form method to GET. This forces the form parameters to be sent as a query string. But again, this is not a smart way to do this.

aaronking
September 23rd, 2008, 02:28 AM
Thanks it works just like how i want it to.

I know its a security issue but I am designing my own server and i needed a way to send the username and password to it using the URL.

Thanks heaps.

PeejAvery
September 23rd, 2008, 07:08 AM
Why would you ever do that? If you are designing your own server...make it able to fetch the username and password in another manner. Any network packet sniffer would harvest these usernames and passwords in seconds.

Xeel
September 23rd, 2008, 12:27 PM
user/password should never be passed via url, less to an html file to process.

- use POST method;
- use somekind of server side class to process/validate the parameters;
- only then respond with a html

html:

<!-- java version -->
<form action="login.jsp" method="post">
<fieldset>
<input type="text" maxlength="10" name="user" />
<input type="password" maxlength="10" name="pwd" />
</fieldset>
</form>

<!-- php version -->
<form action="login.php" method="post">
<fieldset>
<input type="text" maxlength="10" name="user" />
<input type="password" maxlength="10" name="pwd" />
</fieldset>
</form>

java solution:

<%
String user = request.getParameter("user");
String pwd = request.getParameter("pwd");
//then you do what you need to valudate em
%>

php solution:

<?php
$user = $_REQUEST["user"];
$user = $_REQUEST["pwd"];
//same here
?>


If you are new to programming and server configurations I'd suggest php approach: easier to install the server, quicker to test, lots of tutorials in the web.

aaronking
September 23rd, 2008, 11:21 PM
Hello,

Thanks for the code.

I am creating a server using Visual Basic 6.0

When a user requests the page the program which im creating will send that page to the user.

I am creating a custom page feature where it allows me to send a fake page to the server and the software will send a cutom page back to the user.

I know that its a security issue but the page where the login is does not link to another page. So when a user logs in the software will read the login data and that is all.

The login details never go another page even knowing there is page in <form action="login.jsp" method="post"> part of the script.

When you click the submit button it will go an try and request the page but the server software which im writing will know its trying to load that page and will create a fake page for the user as each users details will be different.

I would do this another way if anyknow knows how to connect to a IP and port and send data to that connection and well as reading the data from the connection. Since I don't know how I have to write this mini server that can connect to an IP and send data.