473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Javascript - login problem

I have a website which contains the root directory, a MemberPages directory and a PublicPages directory.
Default.aspx resides in the root directory and includes a javascript login. Upon clicking the Login button the user should be directed to a page within the MemberPages directory. I had this working, however added a new user last night and since then no logins are working. We are in progress on building a fully secure site with SQL Db however until that is complete I need to get this login script working again.
When a user clicks on login the site tries to load the MemberPages page from the root directory. I am looking for some assistance as to how I get it to load the page from the MembersPages directory. I have had to shut part of the site down until this is fixed. I did have it working but in my stupidity I accidentally saved over the code and as I wrote in earlier in the year I have forgotten what it is I did to get it to work.

Code from Default.aspx below. The login button should take the user to ~/MemberPages/BrkrDflt.aspx

Any assistance would be GREATLY appreciated.

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
  2.      Title="Home Page" %>
  3.  
  4. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  5.  
  6.     <!--
  7.  
  8. CONTENT CONTAINER
  9.  
  10. -->
  11.     <div id="content-container-two-column" 
  12.         <span style="font-family: Verdana">
  13.         <!--
  14.  
  15. CONTENT MAIN COLUMN
  16.  
  17. -->
  18.         </span>
  19.         <div id="content-main-two-column">
  20.             <h1 style="font-family: Verdana">
  21.                 WELCOME</h1>
  22.                 <div id="three-column-container" 
  23.                 style="background-image: url('Images/Image1.png'); width: 696px;">
  24.  
  25.                 <div id="three-column-side1">
  26.                     <img alt="" class="photo-border" src="Images/CrctBrd.png" 
  27.                         style="height: 78px; width: 144px; font-family: Verdana;" />
  28.                     <h2 style="font-family: Verdana">
  29.                         Our Products</h2>
  30.                     <p>
  31.                         <span style="font-family: Verdana">
  32.                         <span style="font-weight: normal">We provide speciality insurance on the</span>
  33.                         <span style="font-weight: normal">following</span> <span style="font-weight: normal">products</span>:</p>
  34.                     <p>
  35.                         <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Motor.aspx" Font-Bold="true">> Prestige Motor Vehicle</asp:HyperLink>
  36.                     </p>
  37.                     <p>
  38.                         <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/BPK.aspx" 
  39.                             Font-Bold="True">> Business Package</asp:HyperLink>
  40.                     </p>
  41.                     <p>
  42.                         <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="~/ISR.aspx" 
  43.                             Font-Bold="True">> Industrial Special Risks</asp:HyperLink>
  44.                     </p>
  45.                     <p>
  46.                         <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="~/PLB.aspx" 
  47.                             Font-Bold="True">> Broadform Liability</asp:HyperLink>
  48.  
  49.                     </div>
  50.                 <div id="three-column-side2">
  51.                     <img alt="" class="photo-border" src="Images/Calc.png" 
  52.                         style="height: 78px; width: 144px" /></span>
  53.                     <h2 style="font-family: Verdana">
  54.                         Members Area</h2>
  55.                     <table border="0" cellpadding="3" height="166" style="width: 201px">
  56.  
  57.                         <tr>
  58.                             <td colspan="3" style="text-align: left">
  59.                                 &nbsp;Please select your Username and enter your password to access.
  60.                             </td>
  61.                         </tr>
  62.                         <tr>
  63.                             <td class="style22" height="34">
  64.                                 &nbsp;</td>
  65.                             <td class="style21">
  66.                                 <span class="style19">Username:</span></td>
  67.                             <td class="style23">
  68.                                 <div align="left">
  69.                                     <span class="style19">
  70.                                           <select name=memlist>
  71. <option value='x'>
  72. <option value='TPUA001|22896|KSNSLGLT'>TPUA001
  73. <option value='TPUA002|11718|CXKSLGLT'>TPUA002
  74. <option value='TPUA003|8073|DSPSLGLT'>TPUA003
  75. <option value='TPUA004|60588|DSSSEFLT'>TPUA004
  76. <option value='TPUA005|6615|CTPSLGLT'>TPUA005
  77. <option value='TPUA006|34560|CSNXENMT'>TPUA006
  78. <option value='TPUA007|38934|CWMWENMT'>TPUA007
  79. <option value='TPUA008|21924|ERKSLGLT'>TPUA008
  80. <option value='TPUA009|40257|CSLSLGLT'>TPUA009
  81.         </select>
  82.  </span>
  83.                                 </div>
  84.                             </td>
  85.                         </tr>
  86.                         <tr>
  87.                             <td class="style22" height="35">
  88.                                 &nbsp;</td>
  89.                             <td class="style21" height="35">
  90.                                 <span class="style19">Password:</span></td>
  91.                             <td class="style23">
  92.                                 <div align="left">
  93.                                     <input maxlength="8" name="pass" size="10" type="password" />
  94.                                 </div>
  95.                             </td>
  96.                         </tr>
  97.                         <tr>
  98.                             <td align="center" class="style22" height="34">
  99.                                 &nbsp;</td>
  100.                             <td align="center" class="style21">
  101.                                 &nbsp;</td>
  102.                             <td align="center" class="style23">
  103.                                 <div align="left">
  104.                                     <input class="style15" name="button" onclick="check(this.form)" type="button"  
  105.                                         value="Login"/>
  106.                                 </div>
  107.                             </td>
  108.                         </tr>
  109.                     </table>
  110.                     <span style="font-family: Verdana">
  111.                     <asp:HyperLink ID="HyperLink6" runat="server" 
  112.                         NavigateUrl="~/PublicPages/Apply.aspx" Font-Bold="True" 
  113.                         >> Apply for a Log In</asp:HyperLink>
  114.                     <br />
  115.                     <br />
  116.                     <asp:HyperLink ID="HyperLink5" runat="server" 
  117.                         NavigateUrl="~/ForgotPassword.aspx" Font-Bold="True" 
  118.                         Width="206px">> Forgotten your password?</asp:HyperLink>
  119.                     <br />
  120.                     <br />
  121.                     </div>
  122.                 <div id="three-column-middle">
  123.                     <img alt="" class="photo-border" src="Images/Factory.png" 
  124.                         style="height: 78px; width: 144px" /></span>
  125.                     <h2 style="font-family: Verdana">
  126.                         About Us</h2>
  127.                     <p>
  128.                         <span style="font-weight: normal; font-family: Verdana;">Trinity Pacific acts purely as a wholesale underwriting agency providing 
  129.                         services on general insurance products. We do not deal with the direct public 
  130.                         and only source business from licensed, general insurance brokers.</span><span 
  131.                             style="font-family: Verdana"> </p>
  132.                     <p>
  133.                         <asp:HyperLink ID="HyperLink7" runat="server" 
  134.                             NavigateUrl="~/About.aspx">> Read More</asp:HyperLink>
  135.                     </p>
  136.                     </div>
  137.             </div>
  138.         </div>
  139.         <!--
  140.  
  141. CONTENT SIDE COLUMN
  142. -->
  143.  
  144.         </span>
  145.  
  146.     </div>
  147.     <script language="JavaScript">
  148. <!--        Begin
  149.         var params = new Array(4);
  150.         var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
  151.         function check(form) {
  152.             which = form.memlist.selectedIndex;
  153.             choice = form.memlist.options[which].value + "|";
  154.             if (choice == "x|") {
  155.                 alert("Please Select Your User Name From The List");
  156.                 return;
  157.             }
  158.             p = 0;
  159.             for (i = 0; i < 3; i++) {
  160.                 a = choice.indexOf("|", p);
  161.                 params[i] = choice.substring(a, p);
  162.                 p = a + 1;
  163.             }
  164.             h1 = makehash(form.pass.value, 3);
  165.             h2 = makehash(form.pass.value, 10) + " ";
  166.             if (h1 != params[1]) {
  167.                 alert("Incorrect Password!"); return;
  168.             };
  169.             var page = "";
  170.             for (var i = 0; i < 8; i++) {
  171.                 letter = params[2].substring(i, i + 1)
  172.                 ul = letter.toUpperCase();
  173.                 a = alpha.indexOf(ul, 0);
  174.                 a -= (h2.substring(i, i + 1) * 1);
  175.                 if (a < 0) a += 26;
  176.                 page += alpha.substring(a, a + 1);
  177.             };
  178.             top.location = page.toLowerCase() + ".aspx";
  179.         }
  180.         function makehash(pw, mult) {
  181.             pass = pw.toUpperCase();
  182.             hash = 0;
  183.             for (i = 0; i < 8; i++) {
  184.                 letter = pass.substring(i, i + 1);
  185.                 c = alpha.indexOf(letter, 0) + 1;
  186.                 hash = hash * mult + c;
  187.             }
  188.             return (hash);
  189.         }
  190. // End -->
  191.           </script>
  192.  
  193. </asp:Content>
Nov 23 '10 #1
3 1946
JKing
1,206 Expert 1GB
You have no form on your page but you reference a form several times in your code and try to pass in a form as a parameter to one of your functions. Likely you are getting a javascript error of "form is null" because there is no form.

Storing the usernames and passwords the way you are doing is really bad practice and is a huge security risk. I would skip fixing this and move straight into using a database if at all possible.

Always backup your files before making changes.
Nov 23 '10 #2
Thanks. I am aware this is not the best way to do it, unfortunately I am cannot commence building the database version until the contract is signed (prob in the new year) so I really need to get this working again in the interim.

I am not getting any form errors just that upon clicking the login button that it tries to navigate to the page in the root directory instead of the memberpages directory.

Thanks again.
Nov 23 '10 #3
JKing
1,206 Expert 1GB
Line 169 - 178 you build a string and then send the user to that page. I would try using an alert around your page string to make sure it is where you want to send the user.
Nov 24 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: GreenBayFan | last post by:
Hello, I am a computer science major. I have had HTML and Java, but not any JavaScript. I know they are similar, but there seem to be a lot of functions and methods I am not familiar with. Plus I...
1
by: George | last post by:
Hi. I've deployed a web application on a desktop computer running W2K and IIS. I'm using the desktop as a server. When I try to access the site, either from my development computer or if I...
1
by: Shmuel Shulman | last post by:
Hi When the program tries to refer to a file on the server I get an error saying that the username/password is incorrect although I did log in to the server when I tried to get a file manually...
1
by: Brad | last post by:
I am having a strange login problem that I have been dealing with for a week and cannot find an answer to. I am about ready to uninstall everything and then reinstall it. I am using Visual...
3
by: Joe Fawcett | last post by:
Dear All We have an application where users login, their name/password details are stored in a table, and now we want to add a third party bulletin board that lives in its own virtual directory....
0
by: yinxi | last post by:
I' m trying to integrate an application using a web-based interface to our firm application. it has required login information at the beginning. on the login page it has one field to give in the...
1
by: drewhiggins | last post by:
I've got a JavaScript login form all working. Now what I would like to add is a checkbox where I tick it and it remembers me for next time - I realise it requires Cookie integration, but how???...
3
by: divina11 | last post by:
I'm writting a login script using JavaScript, can someone help with the parts I've commented? Thank you <HTML><HEAD> <TITLE>Login Program</TITLE> </HEAD> <SCRIPT> function validate() {
3
by: igraffman | last post by:
What is wrong with this code that getval is not found? // This function opens the login window. var loginWin; function getval () { return true; document.write ("here I am");
1
by: paulyXvpf | last post by:
Hello javascript folks, PROBLEM: Javascript dropdown problem in IE 6 and IE7 DESCRIPTION: menu falls behind a container box on web page COMMENTS: It works fine in Firefox but not in IE 6/7...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.