Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for next page

Status
Not open for further replies.

simonWMC

Programmer
Dec 2, 2002
180
GB
Hi

I have a Login page,but I can't find the code that tells the browser which page to goto if the login is successful ?

Think i'm being stupid, but can anyone point me in the direction of the correct code ?

cheers
 
response.redirect if nothing has been written to the page or
Code:
<meta http-equiv=&quot;refresh&quot; content=&quot;5;URL=admin/default.asp&quot;>
if html has already been written.

Cheech

[Peace][Pipe]
 
thanks - found the line i think

response.redirect referringpage & &quot;?aicc_sid=&quot;& AICC_SessionID & &quot;&aicc_URL=initializing&quot;

not sure i understand it though
 
Post the code for your login page and the success login page

Cheech

[Peace][Pipe]
 
have no way of posting unfortunatly - could i email ?
 
cut and paste the code then wrap it in [ code ] your code here [ / code ] tags without the spaces

[Peace][Pipe]
 
ok

studentlogin page :

Code:
<%@LANGUAGE=&quot;VBSCRIPT&quot; %> 
<!--#include file=&quot;Connections/LearningSite.asp&quot; -->
<%Response.Buffer = true %>
<%On Error Resume Next%>
<% Dim UserNameVar
UserNameVar = &quot;&quot;
   Dim PasswordVar
PasswordVar = &quot;&quot;
UserNameVar = Request.form(&quot;UserName&quot;)
PasswordVar = Request.form(&quot;Password&quot;)
%>
<%

ActivityIDVar = Request.form(&quot;ActivityIDfield&quot;)
   if ActivityIDVar = &quot;&quot; then ActivityIDVar = Request.querystring(&quot;ActivityID&quot;)
ActivityNameVar = Request.form(&quot;ActivityNamefield&quot;)
   if ActivityNameVar = &quot;&quot; then ActivityNameVar = Request.querystring(&quot;ActivityName&quot;)
ReferringPage =  Request.form(&quot;ReferringPagefield&quot;)
   if ReferringPage = &quot;&quot; then ReferringPage = Request.querystring(&quot;ReferringPage&quot;)
%>
<%'Check to see if the Activity exists.  If not- add it.
  SQLString = &quot;SELECT * FROM Activities WHERE ActivityID ='&quot; & ActivityIDVar & &quot;';&quot;
  set CheckActivity = Server.CreateObject(&quot;ADODB.Recordset&quot;)
  CheckActivity.ActiveConnection = MM_LearningSite_STRING

  CheckActivity.Source = SQLString
  CheckActivity.CursorLocation = 2
  CheckActivity.LockType = 1
  CheckActivity.Open
if Err.Number <> 0 then
   Response.write &quot;The following Error has occured:<br>&quot;&  Err.description & &quot;<br>On line: &quot; & Err.Line
   Response.write &quot;<br>&quot;
end if

  If CheckActivity.Fields.Item(&quot;ActivityName&quot;).Value = &quot;&quot; then

  SQLString = &quot;INSERT INTO Activities (ActivityID, ActivityName, ActivityURL) VALUES ('&quot; & ActivityIDVar & &quot;', '&quot; & ActivityNameVar & &quot;', '&quot; & ReferringPage & &quot;');&quot;
    set CheckActivity = Server.CreateObject(&quot;ADODB.Recordset&quot;)
    CheckActivity.ActiveConnection = MM_LearningSite_STRING 
    CheckActivity.Source = SQLString
    CheckActivity.CursorLocation = 2
    CheckActivity.LockType = 3
    CheckActivity.Open

  end if
Err.Clear%>
<html>
<head>
<title>Student Login</title>
</head>
<body bgcolor=&quot;#FFFFFF&quot;>
<%' Have they entered the info?

if Request.Form(&quot;Submit&quot;) = &quot;Login&quot; then  ' they have pressed the Login button.
  if (UserNameVar <> &quot;&quot;)=True AND (PasswordVar <> &quot;&quot;)=True then  'Are there values in the Name & Password?
%>
<b>
<% ' check to see if they are a student
SQLString = &quot;SELECT * FROM Student_Data WHERE Student_Data.UserID = '&quot;& UserNameVar& &quot;' AND Student_Data.Password= '&quot; & PasswordVar & &quot;';&quot;

  set Recordset1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
  Recordset1.ActiveConnection = MM_LearningSite_STRING
  Recordset1.Source = SQLString
  Recordset1.CursorLocation = 2
  Recordset1.LockType = 1
  Recordset1.Open
%>
</b> 
<% 
   'if Err.Number = 0 then

if NOT Recordset1.EOF then


    ' -- Delete Session ID
    SQLString = &quot;DELETE * FROM Session_IDs WHERE UserID ='&quot; & UserNameVar & &quot;' AND ActivityID='&quot; & ActivityIDVar & &quot;';&quot;

  ' finish the sql and execute it
  Set sessionDelete = Server.CreateObject(&quot;ADODB.Command&quot;)
  sessionDelete.ActiveConnection = MM_LearningSite_STRING
  sessionDelete.CommandText = SQLString
  sessionDelete.Execute
%>
<%

  '-- Write in new SessionID info
  SQLString = &quot;INSERT INTO Session_IDs (UserID, ActivityID) VALUES ('&quot;& UserNameVar &&quot;', '&quot; & ActivityIDVar & &quot;');&quot;

  ' finish the sql and execute it
set sessionInsert = Server.CreateObject(&quot;ADODB.Recordset&quot;)
  sessionInsert.ActiveConnection = MM_LearningSite_STRING
sessionInsert.Source = SQLString
sessionInsert.Open
Dan = sessionInsert(&quot;SessionID&quot;)
%>
<%'block 4 was moved to block 8 due to a speed issue.  Renumber when possible.%>
<%
  ' -- Delete Activity_Detail
   SQLString = &quot;DELETE * FROM Activity_Detail WHERE UserID ='&quot; & UserNameVar & &quot;' AND ActivityID='&quot; & ActivityIDVar & &quot;';&quot;

  ' finish the sql and execute it
  Set detailDelete = Server.CreateObject(&quot;ADODB.Command&quot;)
  detailDelete.ActiveConnection = MM_LearningSite_STRING
  detailDelete.CommandText = SQLString
  detailDelete.Execute
%>
<%
'-- Delete Activity_Status
%>
<%
set GetStatus = Server.CreateObject(&quot;ADODB.Recordset&quot;)
GetStatus.ActiveConnection = MM_LearningSite_STRING
GetStatus.Source = &quot;SELECT Status  FROM Activity_Status  WHERE UserID= '&quot; & UserNameVar & &quot;' AND ActivityID = '&quot; & ActivityIDVar & &quot;';&quot;
GetStatus.CursorType = 0
GetStatus.CursorLocation = 2
GetStatus.LockType = 3
GetStatus.Open()
GetStatus_numRows = 0

StatusVar = GetStatus.Fields.Item(&quot;Status&quot;).Value

if StatusVar = &quot;&quot; then
   'do optional update
end if

   '-- Write in Activity_Status
if StatusVar = &quot;&quot; then 
    SQLString = &quot;INSERT INTO Activity_Status (ActivityID, ActivityName, UserID, ActivityDate, Location, Status) VALUES ('&quot;&ActivityIDVar&&quot;', '&quot;&ActivityNameVar&&quot;', '&quot;&UserNameVar&&quot;', '&quot;& Date() & &quot;', '&quot;& &quot;&quot; &&quot;', '&quot;& StatusVar &&quot;');&quot;
else
    SQLString = &quot;UPDATE Activity_Status SET ActivityDate='&quot; & Date() & &quot;', Status='&quot; & StatusVar & &quot;' WHERE UserID= '&quot; & UserNameVar & &quot;' AND ActivityID = '&quot; & ActivityIDVar & &quot;';&quot;
end if

  set Recordset7 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
  Recordset7.ActiveConnection = MM_LearningSite_STRING
  Recordset7.Source = SQLString
  Recordset7.CursorType = 0
  Recordset7.CursorLocation = 2
  Recordset7.LockType = 3
  Recordset7.Open
%>
<%' ----------------------------------------------------------------------------------------
' add a delay
for i=1 to 100000
next

 '-- Get new SessionID

  SQLString = &quot;Select * From Session_IDs Where UserID= '&quot; & UserNameVar & &quot;' AND ActivityID = '&quot;&ActivityIDVar&&quot;';&quot;
 response.write (&quot;<br>GetSID<br>&quot; & SQLString & &quot;<br><br>&quot; )

  set GetSID = Server.CreateObject(&quot;ADODB.Recordset&quot;)
  GetSID.ActiveConnection = MM_LearningSite_STRING
  GetSID.Source = SQLString
  GetSID.CursorType = adOpenStatic
  GetSID.CursorLocation = 2
  GetSID.LockType = 1
  GetSID.Open

 response.write &quot;Count: &quot; & GetSID.recordcount & &quot;<br>&quot;

  AICC_SessionID = GetSID.Fields.Item(&quot;SessionID&quot;).Value
err.clear
'End if

response.write &quot;AICC_SessionID=&quot; & AICC_SessionID & &quot;<br>&quot;
' ---------------------------------------------------------------------------------------- %>
<% 'if AICC_SessionID > 0 then
   response.redirect referringpage & &quot;?aicc_sid=&quot;& AICC_SessionID & &quot;&aicc_URL=initializing&quot;
  else  'record was not found
%>
<script language = &quot;javascript&quot;>
   alert(&quot;That user was not found.&quot;)
   {history.back()}
</script>
<%  end if  'was student record found? %>
<%  else  'Username and Password are not both filled out 

%>
<script language = &quot;javascript&quot;>
   alert(&quot;You must enter a UserName and a Password.&quot;)
   {history.back()}
</script>
<%'response.write (&quot;You must enter a UserName and a Password.&quot;)
  end if  ' were UserName & Password filled out?



else 'no submit button or one of the fields is null
%>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;studentLogin.asp&quot;>
  <table width=&quot;270&quot; border=&quot;0&quot; align=&quot;center&quot;>
    <tr name=&quot;login&quot;>
      <td>&nbsp;</td>
      <td><img src=&quot;images/login.gif&quot; name=&quot;login&quot; alt=&quot;Login&quot;></td>
    </tr>
    <tr> 
      <td> 
        <div align=&quot;right&quot;>User ID: </div>
      </td>
      <td> 
        <input type=&quot;text&quot; name=&quot;UserName&quot; value=&quot;<%= Request.Form(&quot;UserName&quot;) %>&quot;>
      </td>
    </tr>
    <tr> 
      <td> 
        <div align=&quot;right&quot;>Password: </div>
      </td>
      <td> 
        <input type=&quot;password&quot; name=&quot;Password&quot; value=&quot;<%= Request.Form(&quot;Password&quot;) %>&quot;>
      </td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td> 
        <input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Reset&quot;>
        <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Login&quot;>
        <input type=&quot;hidden&quot; name=&quot;ActivityIDfield&quot; value=&quot;<%=Request.querystring(&quot;ActivityID&quot;)%>&quot;>
        <input type=&quot;hidden&quot; name=&quot;ActivityNameField&quot; value=&quot;<%=Request.querystring(&quot;ActivityName&quot;)%>&quot;>
        <input type=&quot;hidden&quot; name=&quot;ReferringPagefield&quot; value=&quot;<%=Request.querystring(&quot;ReferringPage&quot;)%>&quot;>
      </td>
    </tr>
  </table>
</form>
<p>
  <%end if 'check for submit button

%>
</p>
<p>&nbsp;</p>
</body>
</html>
<%
GetStatus.Close()
%>

success page :

Code:
<html>
<head>
<title>Practise Test</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language='JavaScript' src='scripts/behActions.js'></script>
<script language='JavaScript' src='scripts/behCourseBuilder.js'></script>
<script language='JavaScript' src='scripts/behDragLayer.js'></script>
<script language='JavaScript' src='scripts/behTimeline.js'></script>
<script language='JavaScript' src='scripts/cmi.js'></script>
<script language='JavaScript' src='scripts/elemDragClass.js'></script>
<script language='JavaScript' src='scripts/elemHotaClass.js'></script>
<script language='JavaScript' src='scripts/elemIbtnClass.js'></script>
<script language='JavaScript' src='scripts/elemInptClass.js'></script>
<script language='JavaScript' src='scripts/elemSldrClass.js'></script>
<script language='JavaScript' src='scripts/elemTextClass.js'></script>
<script language='JavaScript' src='scripts/elemTimrClass.js'></script>
<script language='JavaScript' src='scripts/interactionClass.js'></script>
<script language=&quot;JavaScript&quot; name=&quot;cmifrag&quot;>
<!--
//CMI tracking code inserted by CourseBuilder for Dreamweaver
//Copyright 1998-2001 Macromedia, Inc. All rights reserved.
function findcmiframe(sp) {
 if (sp==null) sp=window.parent;
 if (sp.frames.length && sp.MM_cmiframe != null)
  return sp.MM_cmiframe;
 else if (sp != window.top)
  return findcmiframe(sp.parent);
 else return null;
}
var aurl;
function setaurl(url) {
 tmpp=url.toUpperCase();
 if ((pos=tmpp.indexOf('AICC_URL'))>-1) {
  aurl=url.substring(pos+9,url.length);
  if (aurl.indexOf('&')>0)
   aurl=aurl.substring(0,aurl.indexOf('&'));
   aurl=unescape(aurl);
   var tmpurl = window.location.href;
   tmpurl = tmpurl.substring(0,tmpurl.lastIndexOf('/'));
   if (aurl.indexOf('/')==-1){
     aurl=tmpurl+&quot;/&quot;+aurl;
   }
   else if (aurl.indexOf('./')==0){
     aurl=tmpurl + aurl.substring(1,aurl.length);
   }
   else if (aurl.indexOf(&quot;http&quot;)==-1){
     aurl=&quot;[URL unfurl="true"]http://&quot;+aurl;[/URL]
   }
   return true;
  }
  return false;
}
function fndUrl(win) {
 if (setaurl(win.document.location+'') == false) {
  if (win == window.top) return false;
  return (fndUrl(win.parent));
 }
 return true;
}
if (findcmiframe(null)==null) {
 var cmi;
 if (document.command == null) {
 if (fndUrl(window)) {
  document.write('<form action='+aurl+' method=\'POST\' target=\'cmiresults\' name=\'command\'><input type=\'hidden\' name=\'command\'><input type=\'hidden\'  name=\'session_id\'><input type=\'hidden\' name=\'version\' value=\'2.0\'><input type=\'hidden\' name=\'aicc_data\'></form>');
  }}
}
//-->
</script>
</head>

<body bgcolor=&quot;#FFFFFF&quot; onLoad=&quot;MM_initInteractions()&quot;>
<interaction name=&quot;Text_Singleline01&quot; object=&quot;G01&quot; template=&quot;050_Text Entry/010_Text_Singleline_03.agt&quot; includesrc=&quot;interactionClass.js,elemTextClass.js&quot;> 
<div name=&quot;G01Layer&quot;> 
  <div align=&quot;center&quot;>
    <p><span name=&quot;G01question&quot;><strong><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Practice 
      Test </font></strong><br>
      </span></p>
    <p><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>This is your chance to practice 
      the typing test before doing it for real.</font></p>
    <p><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>Simply copy the text below into 
      the box provided. Trying to type as quickly and accuratly as possible.</font></p>
    <table width=&quot;900&quot; border=&quot;1&quot;>
      <tr>
        <td><font size=&quot;3&quot; face=&quot;Arial, Helvetica, sans-serif&quot;>From April 2003 changes 
          to the policing boundaries in Worcestershire will enable West Mercia 
          Constabulary to work more closely in partnership with local authorities 
          to tackle crime and improve the quality of the life for local communities. 
          Following a detailed consultation programme, the force has established 
          a new structure to re-align divisional boundaries to coincide with those 
          of local authority areas across the county. Worcestershire will be served 
          by two divisions &#8211; North Worcestershire, which will cover Bromsgrove, 
          Redditch and Wyre Forest Council areas and South Worcestershire, embracing 
          the whole of Malvern Hills, Worcester City and Wychavon Council areas. 
          The new arrangements will provide greater opportunities for the police 
          and other agencies to work towards joint performance targets for the 
          benefits of local communities. They will also further enhance partnership 
          working in such areas as youth offending teams, the management of potentially 
          dangerous offenders and child protection issues.</font></td>
      </tr>
    </table>
    <p>&nbsp;</p>
  </div>
  <form name=&quot;G01elem&quot; onSubmit=&quot;return false&quot;>
    <div align=&quot;center&quot;>
      <textarea name=&quot;G01elemInp&quot; cols=&quot;145&quot; rows=&quot;10&quot; onFocus=&quot;G01.e['elem'].focus()&quot; onBlur=&quot;G01.e['elem'].update()&quot;></textarea>
    </div>
  </form>
  <form name=&quot;G01controls&quot;>
    <div align=&quot;center&quot;>
      <input name=&quot;G01judge&quot; type=&quot;BUTTON&quot; value=&quot;Submit&quot; onClick=&quot;MM_judgeInt('G01')&quot;>
      <input name=&quot;G01reset&quot; type=&quot;BUTTON&quot; value=&quot;Reset&quot; onClick=&quot;MM_resetInt('G01','reset')&quot;>
    </div>
  </form>
</div>
<script language=&quot;JavaScript&quot;>

<!--

  // Copyright 1998,1999 Macromedia, Inc. All rights reserved.

  function newG01() {

    G01 = new MM_interaction('G01',0,0,1,null,0,1,90,'Practice','','f','0',1);

    G01.add('text','elem','');

    G01.add('textComp','elem','Response1','25-32-###-wlaoksrjfdda1AS',1,1,1,1);

    G01.init();

    G01.am('segm','Segment: Check Time_',1,1);

    G01.am('cond','Time At Limit_','G01.timeAtLimit == true',0);

    G01.am('actn','Popup Message','MM_popupMsg(\'You are out of time\')','pm');

    G01.am('actn','Set Interaction Properties: Disable Interaction','MM_setIntProps(\'G01.setDisabled(true);\')','sp');

    G01.am('end');

    G01.am('segm','Segment: Correctness_',1,0);

    G01.am('cond','Correct_01','G01.correct == true',0);

    G01.am('actn','Popup Message','MM_popupMsg(\'Correct\')','pm');

    G01.am('end');

    G01.am('cond','Incorrect_01','G01.correct == false',0);

    G01.am('actn','Popup Message','MM_popupMsg(\'Incorrect\')','pm');

    G01.am('end');

    G01.am('cond','Unknown Response_','G01.knownResponse == false',0);

    G01.am('actn','Popup Message','MM_popupMsg(\'Unknown Response\')','pm');

    G01.am('end');

    G01.am('segm','Segment: Check Tries_',1,1);

    G01.am('cond','Tries At Limit_','G01.triesAtLimit == true',0);

    G01.am('actn','Popup Message','MM_popupMsg(\'You are out of tries\')','pm');

    G01.am('actn','Set Interaction Properties: Disable Interaction','MM_setIntProps(\'G01.setDisabled(true);\')','sp');

    G01.am('end');

  }

  if (window.newG01 == null) window.newG01 = newG01;

  if (!window.MM_initIntFns) window.MM_initIntFns = ''; window.MM_initIntFns += 'newG01();';

//-->

</script>
<cbi-select object=&quot;G01&quot;></interaction>
</body>
</html>
 
OK i think if you change the line
Code:
<input type=&quot;hidden&quot; name=&quot;ReferringPagefield&quot; value=&quot;<%=Request.querystring(&quot;ReferringPage&quot;)%>&quot;>

to

<input type=&quot;hidden&quot; name=&quot;ReferringPagefield&quot; value=&quot;<%=
]color red]ReferringPage[/color]
Code:
%>&quot;>

You should have more luck

Cheech

[Peace][Pipe]
 
OK, for some reason, when changing that line I can't preview. I just get the page cannot be displayed page in IE.
 
You did spot my mistake?

<input type=&quot;hidden&quot; name=&quot;ReferringPagefield&quot; value=&quot;<%=ReferringPage%>&quot;>

Cheech

[Peace][Pipe]
 
I did wonder - but didn't question - thought it may be some new sort of code ! lol

Cheers - will let you know how i get on
 
Hmmmm, still the same. Just resets the page.

I am using learning site. And have this morning ditched it all and started again - but hit the same problem. tried changing the code as you recommended but still not working.

I don't have a very good understanding of .asp. Should i be able to test this page susccesfully on my testing server (local machine) ?
 
I am now thinking that maybe the problem lies in the navigation.htm page

any idea how you control the referingPage variable ?
 
in general on variables & HTMLs:


u can pass them as/through links or forms......consider them as a shopping list given to you by your demanding wife :)
it is a list of things that u need to search for:
so instead of going arround with 10 'sticky notes' (variables) u can use one long list (entire querry string)
or u can collect or all of your &quot;sticky notes&quot; asu go through the pages and build them into one.
For the ASP concept follow the link above....
All the best!

> need more info?
:: don't click HERE ::
 
problem sorted - thanks guys

there was no problem with my pages - it was the frameset !

cheers !
 
SIMON -
What was the solution to your issue??? I'm having the same problem using learning site. After a successful Login, the user gets a blank screen! Help.

Thanks!
 
Hi baltimoreboy,

my issue originally was - that when i previewed the loginpage - it didn't go to the page i expected it to. This was because I was using learning site, and you have to get to the login page from another page.
So i created a new page with a link to studentlogin.asp
The login page will then automatically link to your index.htm page.

Note : this only applies if you are using learningsite
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top