View Full Version : Forms - Username
jaime0007
08-30-2005, 02:10 PM
Hi everyone!
I have a website with pasword protection on it. It is a free hosted service by BFNdevelopment.com. As i use Freewebs.com (on advance user)
What i want is:
When one of my members login to their account using their username and password i want their username to be displayed on the next page, as a welcome.
1) login using the username "Ben01"
2) redirects to the main site and says "Welcome Ben01"
PS: i have full control over the script, it is not a hosted page (just hosted SCRIPT)!
Can anyone understand that? can you help? Pllllleaaasseeee
Thanks!!! :thumbsup:
nikkiH
08-30-2005, 02:46 PM
If the two pages are not in the same domain, you generally can't use cookies, so pass the user name to the new page as a url param and grab it with JS.
i.e.
location.href = "newURL?username=ben";
jaime0007
08-30-2005, 02:53 PM
ok, that made no sence to me! :S lol sorry!!!!!!:confused: :o
the login page is http://www.freewebs.com/bumtingz03/
and the page after that (where i want the username to appear saying "welcome ben01") (ben01 is an example, i have over 200 users) is http://www.freewebs.com/bumtingz03/Logging%20in%20redirecting.htm
(if u go on the redirecting one it will just say "members only" as it knows you havnt entered an account)
Thanks......now what lol :o :confused:
nikkiH
08-30-2005, 04:52 PM
Okay, first things first.
People are logging in before they are redirected, yes?
What mechanism is taking care of that and checking that they are, in fact, logged in? Looks like a cgi to me...
Does the API give you access to the user name? You need the thing that logs people in to tell you their name (or you need to capture it when they log in to begin with).
This API:
<script language =" JavaScript" src =" http://www.bfndevelopment.com/cgi-bin/home/Members/Environment/Environment.cgi?User=13673">
What else can it tell you besides the IP address?
jaime0007
08-30-2005, 05:06 PM
<script language = "JavaScript" src = "http://www.bfndevelopment.com/cgi-bin/home/Members/Environment/Environment.cgi?User=13673">
// bfnIP - Contains the users IP address
// bfnUserAgent - Contains the users User Agent information, including browser.
</script>
Here is the script that determins wether or not you have logged in:
<script language = "javascript">
<!--
/*
Protect pages from being accessed without logging in first
Black Fire Networks - http://www.bfndevelopment.com
*/
var RequiredPathPrefix = "http://www.bfndevelopment.com/cgi-bin/home/Members/Password/NetLock.cgi?SiteID=13673&LockID=4157";
var RelocatePath = RequiredPathPrefix + "&Frame=1";
var FramePath = parent.location.toString();
if (FramePath.substring(0, RequiredPathPrefix.length) != RequiredPathPrefix) {
parent.location = RelocatePath;
setTimeout('document.write("<html></html>")', 10);
alert("Members Only!" + "\n" + "Please login first");
}
-->
</script>
-----------------------------------------------------------------------
and heres the login script:
<form action = "http://www.bfndevelopment.com/cgi-bin/home/Members/Password/NetLock.cgi?SiteID=13673&LockID=4157&Frame=1" method = "POST">
<input type = "hidden" name = "login" value = "false">
<!-- if "true" and someone tries logging in with no username, they will be -->
<!-- prompted to enter there username and password again, on our template -->
<table border = 0 cellpadding = 1 cellspacing = 0 width = 300 height = 100 bgcolor = #000000>
<td width = 300 height = 100>
<table border = 0 cellpadding = 0 cellspacing = 0 width = 300 height = 100>
<td height = 20 width = 300 bgcolor = #1111AA>
<table border = 0 cellpadding = 0 cellspacing = 0 width = 300 height = 20>
<td>
<center><font face = "arial" color = #FFFFFF size = 2><b>
Member Login
</b></font></center>
</td><td width = 20 height = 20>
<center><img src = "http://www.bfndevelopment.com/x.gif" border = 0 onClick = "history.go(-1)"></center>
</td>
</table>
</td><tr>
<td height = 20 width = 300 bgcolor = #FFFFFF>
<table border = 0 cellpadding = 3 cellspacing = 0 width = 300 height = 20>
<td width = 20>
<font face = "arial" size = "2"><b>Username:</b></font>
</td><td>
<input type = "text" name = "UserName" size = 29>
</td><tr>
<td width = 20>
<font face = "arial" size = "2"><b>Password:</b></font>
</td><td>
<input type = "password" name = "PassWord" size = 29>
</td>
</table>
</td><tr>
<td bgcolor = #FFFFFF valign = "bottom">
<table border = 0 cellpadding = 5 cellspacing = 0 width = 300 height = 10>
<td width = 300 height = 10>
<div align = "right"><input type = "submit" value = "Login"></div>
</td>
</table>
</td>
</table>
</td>
</table>
</form>
AAAAHHHHH, sorry if im making no sence! thanks for the help! :confused: :o :thumbsup:
nikkiH
08-30-2005, 05:16 PM
Okay, basically, no, you can't get their user name.
You can try writing a cookie with the value they enter in this form, but if they enter nothing, they are redirected to a different form you have no control over. So it's iffy at best.
I'd ask the people who own that cgi to make the username available as they do the IP address.
jaime0007
08-30-2005, 06:02 PM
ok i contacted BFN and....... (read from bottom up)
----------------------------------------------------------------
Not off hand, setting cookies in javascript takes a
bit of code, and I dont have any to give you. If you
do a search around the net, you should be able to find
some cookie setting functions pretty easily.
- Black Fire
---------------------------------
Ok thanks.......
would you be able to give me the javascript?
Thanks again
--------------------------------
>If you know javascript, you can setup a form
>validation script, that stores the username in a
>cookie. You can then recall the stored username on
>other pages in your site. This is basically the only
>way to do it, it wouldnt be efficient to do it server
>side on our end. Let me know if you have any more
>questions.
> > ------------------------------
> > Message:
> > Hi,
> > Would you be able to make a script that allows
> > people to show the username someone entered on the
> > protected page.
> >
> > for example:
> >
> > 1) login using the username "Ben01"
> > 2) redirected to the protected page and it says
> > "Welcome Ben01"
> >
> > Could you maybe do that? Maybe inclued it in the
> > Enviromental Data script?
> >
> > Please email back!
-------------------------------------------------------------------
haha :mad: :eek: :( now what :S :thumbsup:
nikkiH
08-30-2005, 07:07 PM
Cookie scripts are all over, but as I said, if it re-directs to another form (invalid login, etc), it won't work.
I have very simplistic cookie functions (no domain stuff, etc) here (http://www.ipwebdesign.net/useful_cookies.html).
Using those, you'd do something like
<form onSubmit="setCookie('mycookiename',this.UserName.value,20)">
(20 days expire time)
If you want a more robust cookie script, Google has plenty of matches. Just use that in place of my setCookie function.
Then when you want to retrieve it, you just do something like
<p>Hi there
<script type="text/javascript">
document.write(getCookie('mycookiename'));
</script>
</p>
(though I'd use something better than document.write, but you get the idea, I hope)
Does that help?
jaime0007
08-30-2005, 07:22 PM
Oh god! lol ill never get the hang of this cookie world!
Heres my Login page script:
Could you tell me where to put the bits?
<form action = "http://www.bfndevelopment.com/cgi-bin/home/Members/Password/NetLock.cgi?SiteID=13673&LockID=4157&Frame=1" method = "POST">
</font><font style="font-size: 9pt">
Username:
</font></b>
<span style="font-size: 9pt">
<font face="Arial" color="#FFFFFF">
<input name = "UserName" size = 10></font><br>
Password<font style="font-size: 9pt; ">:
</font><font face="Arial" style="font-size: 9pt; font-weight: 700">
<input type = "password" name = "PassWord" size = 10></font><font style="font-size: 9pt; ">
</font><font face="Arial" style="font-size: 9pt; font-weight: 700">
<input type = "submit" value = "Enter My Account"></font><font face="Arial" style="font-size: 9pt; ">
And heres the page it redirects to once logged in:
<html>
<head>
</head>
<body>
<p>Hi there
<script type="text/javascript">
document.write(getCookie('mycookiename'));
</script>
</p>
</body>
</html>
Is that right?
:o Sorry if im being a pain! :o :confused:
jaime0007
08-31-2005, 04:04 PM
Can any1 help??? :o
I found this......dunno if this will help anyone who knws what they are doin :S but its close to what i need............isnt it? lol
http://www.huntingground.freeserve.co.uk/scripts/cookies/cookie_ex1.htm
jaime0007
08-31-2005, 06:37 PM
can someone pleeaaasssse help :( :o :confused:
canadianjameson
08-31-2005, 07:51 PM
hmmm... although i dont know the code... couldnt you just save the value of the username field to a serverside variable and then display that variable on the page once they log in?
i.e: var userNameToBeDisplayed = userNameField.value;
anyways, i dont know but someone might be able to run with that
jaime0007
09-01-2005, 04:32 PM
ok thanks m8, not sure if that would work tho? :S
http://www.huntingground.freeserve..../cookie_ex1.htm
Would that work at all?
just needs some1 to break it up......sum1 who knows what they are doin :o
jaime0007
09-07-2005, 09:06 PM
has anyone got a solution yet :'( lol?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.