BookmarkSubscribeRSS Feed
Attyslogin
Obsidian | Level 7

 

Dear all..

My motive is creating a login page simply & if user click submit button by entering correct credential then my choice  macro [here in code it is  "index page"]  should run. 

 

i have developed this code and it is working fine except  my index_page macro output gets appended to the same page. i.e. _webout not clearing out previous contents.

i tried n ways options to close _webout but couldnt succeed. Any suggestions to the same code ? any other way to do the same?

 

kindly give your inputs. Thanks ! 

 

And yeah i have created stored process for this code where i have excluded stored process macros %stpbegin %stpend.

 

 

Code :  

 

 

%MACRO LOGIN_PAGE;
data _null_;
file _webout;
PUT '<HTML>';
PUT '<HEAD> <TITLE> TITLE GOES HERE</TITLE>';
PUT '<STYLE>';
PUT 'BODY {COLOR:#d66a00; BACKGROUND:WHITE}';
PUT '.LOGIN_WINDOW { PADDING: 10PX;WIDTH:100PX;PADDING:30PX; COLOR:BLACK; background-color:WHITE; border: 3px solid LIGHTGREY;MARGIN:5em auto 0}';
PUT 'button { background-color: #a65200;color: white; border:none; cursor: pointer;width: 100PX;}';
PUT '</STYLE></HEAD>';
PUT'<BODY>';
PUT '<H1><CENTER> PAGE HEADING GOES HERE </H1> <BR>';
PUT '<form action='"&_URL"' method="POST">';
PUT '<INPUT TYPE="HIDDEN" NAME='"_PROGRAM"' VALUE='"&_PROGRAM"'>';
PUT '<div class="LOGIN_WINDOW">';
PUT '<label><b>Username</b></label><BR><input type="text" name="uname" required><BR><BR>';
PUT '<label><b>Password</b></label><BR><input type="password" name="psw" required><BR><BR>';
PUT '<button type="submit"><B>Login<B></button>';
PUT '</div>';
PUT '</FORM>';
PUT'</BODY>';
PUT'</HTML>';
RUN;

%MEND LOGIN_PAGE;


%MACRO INDEX_PAGE;
DATA _NULL_;
FILE _webout;
PUT '<HTML>';
PUT '<HEAD> <TITLE> INDEX PAGE </TITLE>';
PUT '<STYLE>';
PUT 'BODY {COLOR:#d66a00; BACKGROUND:WHITE}';
PUT '</STYLE>';
PUT'<BODY>';
PUT '<H1> <CENTER> WELCOME <CENTER> </H1> <BR>';
PUT'</BODY>';
PUT'</HTML>';
RUN;
%MEND INDEX_PAGE;


/*---------------EXECUTION SEQUENCE----------------*/

%MACRO MAIN;

%LOGIN_PAGE;

%IF "&UNAME"="HI" %THEN %INDEX_PAGE;
%MEND MAIN;
%MAIN;

4 REPLIES 4
ThomasPalm
Obsidian | Level 7

Hi.

You just need to make sure that your "login_page" macro doesn't run if a username is submitted.

It could be something like

/*---------------EXECUTION SEQUENCE----------------*/
%MACRO MAIN;
%IF "&UNAME"="HI" %THEN %INDEX_PAGE;
%ELSE %LOGIN_PAGE;
%MEND MAIN;
%MAIN;
Attyslogin
Obsidian | Level 7

Its not working for me. Now its showing twice login page as else part is executing at initial pass. 

ThomasPalm
Obsidian | Level 7

This is working on my end in ordinary sas:

%global uname;
%let uname=HI;

%MACRO LOGIN_PAGE;
	%put Login_page;
%MEND LOGIN_PAGE;

%MACRO INDEX_PAGE;
	%put Index_page;
%MEND INDEX_PAGE;

/*---------------EXECUTION SEQUENCE----------------*/
%MACRO MAIN;
	%IF &UNAME eq HI %THEN %INDEX_PAGE;
	%else %login_page;
%MEND MAIN;
%MAIN;

Are you sure, that you are using the changed code in your stored process?

Attyslogin
Obsidian | Level 7

yeah .... still no success

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 842 views
  • 0 likes
  • 2 in conversation