User Name appears on all pages

I *think* this is a CGI question.  From some responses I received on newsgroups, it can't be done in Java or in regular html.

I've seen some sites where after the user enters their name in a form then their name appears (nicely formatted) at the top of various subsequent pages.

Well, here's what "I" need.

The scenereo:

1.  The person arrives at index.htm.  They are prompted for a five digit number.  The person enters "1234".  This sends the person to 1234.htm   But at the same time, I need the numbers "1234" to be stored so that later, the numbers "1234" can appear anywhere on any subsequent page, anywhere I want them to.  

2.  Just to make sure my request is clear, when another person later arrives at index.htm, and they enter THEIR passnumber, which is "5678", they are sent to "5678.htm", and at the same time the number "5678" is stored, so it can be used on subsequent pages, anywhere I want them to.  

Perhaps a cookie is involved, but there is no need for the cookie to remember the person's visit past once they leave the site.

Again, no other imput from the person other than those four numbers.  No user name.  Just those four numbers.

Thanks for any thoughts, suggestions -- and solutions!

Rowby GorenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

<input type=hidden name=user value=5678>
Rowby GorenAuthor Commented:
Okay  That looks easy enough!  But I'm not quite sure how to impliment it.  I don't know anyting about CGI.  For example, how do I then get that 1234 to pop up on a subsequent page?   Is there some kind of an anchor I place?

And will you solution work on all the usual servers?  I am using TABnet and can I simply show them your answer -- and then they can tell me if it will work on their system.  In other words, will they understand your rather "brief" answer and give me a "yes" I can use it on their server.  (I hope I am making myself clear!)

use CGI qw(:standard);
print header;
if( param('user') ){
        param('page',$page = param('page')+1);
        print start_html("Page $page");
        print h1("You are number ".param('user')),
          submit(-name=>'next page'),
        print start_html('Title'),
          start_form,"What's your number?",textfield('user'), p,
          submit, end_form;
print end_html;

Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Rowby GorenAuthor Commented:
Well I don't know CGI but looking at your response, I guess that answers my question.

I will forward your answer to my provider, and, if they respond positively I will award you the points!

In the meantime, if you feel you need to further respond to the question, don't hesitate.

I'll send the response to them Saturday!

By the way, just to make sure, will the script you provided also take the person "1234", when he pushes the submit button, to page "1234.htm" at the same time as it is storing the number 1234 for later use?  
Actually, it takes the person back to the same cgi prog, since it wants to keep writing
<input type=hidden name=user value=1234>
on all subsequent pages.
You might have done something like

if( param('user') ){
       if( open(HTML,"<".param('user').".htm") ){
                print <HTML>;
                print("Can't open ".param('user').".htm because $!");

With the assumption that 1234.htm will contain
<input type=hidden name=user value=1234>

Rowby GorenAuthor Commented:
Okay I guess you did it!  And I will provide all of your replies to my ISP.

One more thing.  (Have I gone to the well once too often).  What if the person enters a number which does NOT correspond to any of my "X.htm" pages.  For example if they arrive at index.htm and they enter  "2134" and there is NO "2134.htm" page.  I would like them to be sent to "error.htm".

Can you add that code to your CGI code.  And to show you how I appreciate your continued help, I have just increased the points to....149!


Well, rather than using Perl, you could actually use JavaScript, What you would do is simply set up a single frame document the parent would be hidden behind a child of width 100% within the parent you would have a variable named something like name=0;
Then when the user types in their login/password you can set this variable (name) to their specific number, then you can reference this number in any of your normal html pages by referencing the variable in the following way:
// --></SCRIPT>
which will print the number exactly as if you had just typed the number into the html document.
Much easier, and server efficient than using a CGI script for doing something like this...
JS can also be coded to detect when a page does not exist.
Hope this provides an alternative answer, I'll post up the
main source that you need to acomplish all of this if you find this as an acceptable answer.
Robin (twexperts)
Rowby GorenAuthor Commented:
Well that sounds interesting!

And because I don't understand everything you're saying, please let me make sure that your solution will handle all of my needs.


User 1234 arrives at index.html

User types in 1234 into an imput box and then clicks on a submit button.

Two things happen:
1 -- the user is taken to 1234.html
2 -- the number 1234 (and, now that I think about it, possibly his name...if that is no problem -- but please, the user would only type in 1234 -- and somehow there would be an easily updatable external "database" or text file which would associate 1234 with the following data which would be outputted onto the any page I desire: "John Doe, Member 1234". -- but if that complicates things too much, then the inclusion of the name is not absolutely necessary.)

Now, one more thing.  And I don't think it changes anything.  I would not necessarily want his number/name on every page.  Only on certain pages.  And, it would be nice if I could position that name at any point on that page, and also nice if I could select the font size and color.  Looking over your solution, it appears you have provided for all of this.

Is that too much of a request?!



To give a more exact answer.  Could you give the web server and hardware platform you are using?
Rowby GorenAuthor Commented:
I have forwarded your question to Tabnet's tech support department.  While waiting for their response, the following may or may not help. It is from tabhet ('s FAQ regarding CGI scripts:

"With a Virtual Server account you have full use of the Operating System and can run CGI connecting to: server-side includes, Perl, C, and C++. You can create your own  CGI-BIN and run your own CGI programs."

I know nada regarding Perl, C, C++ CGI or Unix.  But perhaps the above gives you a clue!  I can tell you this, I am not running Front Page.


This is what I can do for you....
> 1 -- the user is taken to 1234.html
No problem what so ever.
> 2 -- the number 1234 (and, now that I think about it, possibly his name...if that is no problem --
This can be done, however, how about having the user's information hidden within their associated html page, eg 1234.html would contain all detailed information about the user 1234 which would then be stored in a hidden frame once accessed?
Otherwise you would more than likely need a perl/cgi script which accesses a more secure database of user information.
Also note that using JavaScript would mean that about 3% of net users would not be able to use the page, however all the main browsers can use it (IE,NN etc etc.).
The font and size can be anything you want at all, even an image file if you want a picture of the person. And you can deside which pages do and do not display any or all of the information about the user.
Just on another thought, have you considered using cookies? If the user is only going to access the site from the same browser each time, then you could use cookies, that way the page can detect who the user is without the user even typing in anything at all, and so the user could be taken directly to their associated page. This is would be a low security solution, and
the user would have to have their browser to accept cookies, which most default to yes anyway...
Hope this gives you a bit more insight.

Rowby GorenAuthor Commented:
I don't need a secure database for this site.  Security just isn't an issue with the people who I am dealing with.  So your java solution seems the way to go -- I guess!

ANd I like your suggestion about having all the information regarding the user on the associated hidden page.

I don't mind about losing the 3 percent who don't have Java. No problem there.

Because different people will be accessing the site from assorted computers, cookies would not work in this case.

Your solution sounds very exciting!  I can't wait to see it.

In case YOU need information regarding the web server and platform (I don't think you do, for your solution) I just spoke with my server, it's TABnet and they inform me that they are using an Intel Platform with BSDI Unix version 3.  It's Apache web server.  They think it's version  1.3.

Looking forward to seeing your solution!!

Ok then, I'll manufacture the code to do all this and post up the code and a demo url for you to take a look at later tonight/tomorrow morning.
Rowby GorenAuthor Commented:
Great!  Thank you for what looks like a very creative solution to my question.  

I am looking forward to seeing your code and its results!

I appreciate your help -- as well as the help of the others who have commented on my Question.

Rowby Goren
Rowby GorenAuthor Commented:
To further respond to Maholt (and anyone else who needs this information, the following is a portion of Email I just received from Tabnet in response to Maholt's request for platform informaiton:


We run Intel platforms with BSDI Unix Ver. 3 and Apache webserver (httpd)
Ver. 1.3

The sendmail is at:  /usr/sbin/sendmail   and perl is at:  /usr/bin/perl
or  /usr/bin/perl5


Ok here's the demo url, source, and instructions on how to implement it all.
demo url:
I've tested it on NN3,NN4, and IE4, works the same in all cases.
In the index.html file there are two variables:
validuser (=9999). Use this value as the maximum user number if you assign each user a number above the previous user.
validusr (=new Array(1000,1001,2050)). Use this array if you
assign each user a random login number, just add the number to
the end of the list, separated by commas. The script will
search this array to see if the number entered is valid.
I've also written a small function to make getting the info
a bit easier, look at the 3rd source file for implementation
of it.
That should be all, email me with any and all questions that you have:
It's been a fun one,
Robin (twexperts)

Here's the source:
********index.html - main driving source
<HTML><TITLE>Demo - Remember Me!!!!</TITLE><HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
validusr=new Array(1000,1001,2050);
function writeinfo(inforeq,font,size,color) {
   if(font=="") { font=defaultfont; }
   if(size=="") { size=defsize; }
   if(color=="") { color=defcolor; }
   t.write("<FONT SIZE="+size+" COLOR="+color+" FACE='"+
function processid() {
   if(number=="") {
   if(number>validuser) {
   validids=new String(validusr.join(","));
   if(validids.indexOf(number)==-1) {
function write_error() {
   document.frames[0].document.write("<H2>You Entered an invalid ID number</H2><BR>");
   document.frames[0].document.write("<A HREF='main.html'>Try again!</A>");
// --></SCRIPT>
<FRAME SRC="main.html" NAME="MAIN">

*******main.html - login page
Beyond this point please do not hit your browsers reload, or back button.<BR>
<FORM ACTION="#" NAME="form1">
<TR><TD><CENTER>Please input your ID number:</TD><TD><CENTER>
<INPUT TYPE="TEXT" SIZE=4 MAXLENGTH=4 NAME="idnumber"></TD><TD>&nbsp;&nbsp;
<INPUT TYPE="BUTTON" NAME="next" VALUE="---- Enter ----" onClick="parent.processid()">

******1000.html - Sample user's file page
<SCRIPT LANGUAGE="JavaScript"><!--
parent.address1="Some Apartment Number";
parent.address2="Some Street Adress";"Minneapolis";
//  --></SCRIPT>
Hello User
<SCRIPT LANGUAGE="JavaScript"><!--
parent.writeinfo(parent.number+" (","Helvetica","5","blue");
parent.writeinfo(parent.f_name+") ","Helvetica","5","blue");
//  --></SCRIPT>
How are you today?<BR>
<P>We have just sent an order to your address as listed below.</P>
(note the font, font size, and color freedom)<BR><P>
<SCRIPT LANGUAGE="JavaScript"><!--
document.write(" ");
document.write(", ");
//  --></SCRIPT>
If this is not the correct address please send us an email at:
<A HREF=""></A>
<P>Just for demo purposes, you can also insert this information into
any generic page common to all users</P>
<A HREF="generic.html">Generic page link</A>
<A HREF="main.html">Log on as a different user</A>


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby GorenAuthor Commented:
Thanks for your solution, however I am
having a problem with a Java error message both
when trying to make it work at your url and when
trying to make it turn on my own at my test URL.

At your site it returns a Javascript error on line

"Window.document.frames has no property indexed by

I'm using Netscape 3.4 gold

Any thoughts?

Thanks, Rowby

P.S. For some reason, my email addressed to was returned as undeliverable.
try it again at my url, and press the web-button rather than the return key first. Thanks for the info on the email address, you should be able to send it to me now.
I'll do some more refining of it tonight, see if I can trim off the rough edges....
I'm sorry it didn't work for you, it really does work great...
Ok, got it fixed, and running properly for NN3 :)
only a minor change, in the index.html document replace all document.frames[0] with frames[0] that's all, silly mistake really. here's the updated url again:
Valid user id's are 1000,1001,2050
Have fun,
hmmm, looks good. I think twexperts deserves his points :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.