Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
David

Two Forms, One Page - Display Only One Form, Not Both

Recommended Posts

Hello there!

 

The thread referenced (at the bottom) covers how to display two forms on a single page.

 

However . . .

 

In the case referenced, both forms are visible on the page by default, and it is only *after* a submit has been detected that the script detects the form sent, and calls the appropriate code.

 

It seems possible to display only one of the forms based on a user's site visit status.

 

For example, assume a page contains code for both 'Form A' and 'Form B'.

 

What I'm looking for is:

 

1) When the user visits the page for the first time, 'Form A' is displayed by default, then;

 

2) On any subsequent visit to the page by the same user, during the same session, 'Form B' is displayed by default.

 

Of course, the submit still gets handled by the processing script, but that's already been covered in the thread referenced.

 

What's got me snookered is how to determe the visitors status (i.e., new or return visit) so that the appropriate form can be displayed.

 

 ~ David

 

Reference:

http://www.larryullman.com/forums/index.php?/topic/1362-two-forms-on-one-page/

Share this post


Link to post
Share on other sites

Probably the simplest solution is to store the user's status in a session (or cookie) variable, and then use that variable in an if-else statement to determine which form to display.

Does that help?

Share this post


Link to post
Share on other sites

Does that help?

 

Indeed it does. Thank you.

 

And since there are already sessions at work, the task is conveniently accomplished.

 

Makes me wince to recall how profound the original question appeared at the time.

 

 ~ David

Share this post


Link to post
Share on other sites

I know how you feel though. When you don't know how to approach a new problem, a bunch of (very complicated) possibilities run through your head, but once you realize what to do, it's usually pretty simple.

Anyway, glad you got what you wanted.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...