Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-14-2010, 02:43 AM   PM User | #1
JsNovice10
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
JsNovice10 is an unknown quantity at this point
Question Javascript Coding for Perl Chat Question

Hi,

I'm still in the early stages of learning Javascript so I'm not sure how (or if it's possible) to do this. I know HTML, CSS, etc... just not too familiar with Javascript. Here's the deal.... I run a website that features a chat room written in Perl for CGI. The chat room will automatically email a user their password if it's forgotten but there is one issue.....it does not have the "Forgot Password?" link. To achieve the Lost Password page, the user must enter an invalid password FIRST on the login screen, otherwise they cannot get to that option and are often requesting assistance.

What I had in mind was an easier way for the user to get their password since new novice members are not sure how to get to the lost password page. I'm not trying to edit the Perl code for the chat, but I wanted to build a "Forgot Password?" page using a Javascript code that will automatically take their username from the "username" login field and direct them to the lost password page which would be "chat2.cgi?action=send_pwd&name=..."

I'm sorry if this is confusing, I'm not sure that I am explaining this right. When the user enters an invalid password, it takes them to the lost password page which contains a link "lost password" and will automatically email them their login details when clicked on. When they click that link, the URL contains the string "chat2.cgi?action=send_pwd&name=username"

What I would like to do is put a link on the login page (like most normal chat rooms have) that says "Forgot Password?". When clicked on, I want it to take them to a page where all they have to do is enter their username in a form and click Submit, then have a Javascript code automatically extract their username from that field and insert their username automatically to the end of that URL (chat2.cgi?action=send_pwd&name=...) where ... would be the name extracted from that form field. This would result in the browser taking them to that URL which would trigger the chat to automatically email the password. Can I do this with Javascript?? If so, any help would be greatly appreciated!
JsNovice10 is offline   Reply With Quote
Old 04-14-2010, 04:14 AM   PM User | #2
Gjslick
Regular Coder

 
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Gjslick will become famous soon enough
You actually don't even need JavaScript at all for this. All you need is an HTML form that submits using the GET method. This will take all of the form fields, create a URL query string out of them, and append them to the form's action as the request.

Try this:
Code:
<form action="chat2.cgi" method="GET">
  <input type="hidden" name="action" value="send_pwd" />

  Enter Username: <input type="text" name="username" />
  <input type="submit" value="Retrieve Password" />
</form>
When that form is submitted, the request will look like this:
chat2.cgi?action=send_pwd&username=whateverWasEntered

Try that and let me know how it goes.

-Greg
Gjslick is offline   Reply With Quote
Old 04-14-2010, 04:54 AM   PM User | #3
JsNovice10
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
JsNovice10 is an unknown quantity at this point
Smile

WOW! It works!! Thank you so much! I have been using HTML for 2 years now and never knew that the GET method would do that!!

I just built a password recovery page with a form using the GET method as you suggested and upon submitting the form, the chat responded saying that the password was successfully sent! Again, thank you so much....this is a project I have been trying to do for a while now and I never knew it was that simple!

--Allen
JsNovice10 is offline   Reply With Quote
Old 04-14-2010, 05:06 AM   PM User | #4
Gjslick
Regular Coder

 
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Gjslick will become famous soon enough
Haha, well glad I could help!

All the best man,

Greg
Gjslick is offline   Reply With Quote
Reply

Bookmarks

Tags
chat rooms, forms, javascript, password, perl

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:56 PM.


Advertisement
Log in to turn off these ads.