Consultor Eletrônico



Kbase 21747: Example of Self-Posting Logon Page (WebSpeed 3.x)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   2/4/2002
SUMMARY:

There are many ways to validate user-supplied information against the database. This example provided here uses the self-posting method. Once the basic principals are understood, the form can be modified a number of ways depending on the coder's goals and needs.

EXPLANATION:

A self-posting form means that the information in the form is collected and submitted to itself. Then, in the output-headers Procedure we can determine if all the qualifications have been met before proceeding forward. If all information is verified we can then either redirect to a new page or use conditional display statements to offer additional functionality.

NOTE: Remember to check for the submit value so checks are not performed at the initial viewing of the form.

SOLUTION:

Copy the following code into a new blank page. Save and compile as logon.html.

--------------------------logon.html-------------------------------

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<Title>An Example of A Logon Screen</title>
<head>
<meta name="AUTHOR" content="Alex Pearlstein">
<script language="SpeedScript">
def var logon as Character.
def var password as Character.
def var WrongPW as logical init true.


PROCEDURE output-headers:
/*Gets the fill-ins values*/
assign logon = get-value("logon").
Assign password = get-value("password").
/*Does the security check*/
/*Note that we check to make sure the submit button*/
/*was pressed so we don't perform a check upon load of the page*/
IF get-value("SubmitBtn") = "Submit" THEN do:
Find first Salesrep where SalesRep = logon and salesrep = password no-error.
/*If the security check passes where to redirect to*/
IF available salesrep THEN do:
/*This Method is redirecting to a new site.*/
/*You may call a separate page instead using the RUN statement*/
/*Cookies would also be set in this block if needed*/
OUTPUT-HTTP-HEADER("Status","302").
OUTPUT-HTTP-HEADER("Location","http://www.Progress.com").
OUTPUT-HTTP-HEADER("","").
END.
/*In case the Security Check fails*/
Else
Assign WrongPW = false.

END.

END PROCEDURE.

</script>
</head>

<body>
<Form method="Post" action="logon.html">
<h1><center><b>Customer Login</center></b></h1>
<center>
<table border="0" cellpadding="2" cellspacing="0" bgcolor="white">
<TR>
<TD><Font size="4">Logon</TD>
<TD>
<input type="text" size="20" name="logon" value=`logon`>
</TD>
</TR>
<TR>
<TD><Font size="4">Password</TD>
<TD><input type="password" size="20" name="password"></TD>
</TR>

<!-- The Go Button -->
<TR>
<TD colspan="2"><center>
<input type="submit" name="SubmitBtn" value="Submit">
</center></td>
</TR>

<script language="SpeedScript">
/*Conditionally Displayed line to identify incorrect information*/
If WrongPW = false and get-value("SubmitBtn") = "Submit" then
{&out} ' <TR>'
' <TD colspan="2">'
'<Center><Font color="RED">Sorry that is the incorrect logon</TD>'
' </TR>'.
</script>
</center>
</Table>
<BR><BR>
<BR><Center>This example uses Sales Rep's names for both fields.
<BR><Center>A proper logon would be HXM for both fields.
</body>
</html>