To make multiple pages in the same page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • learnPHP
    New Member
    • Mar 2008
    • 20

    To make multiple pages in the same page

    Hi

    I have 3 PHP pages with different names for a common survey. the first page has 8 questions next page the next 8 and so on. I have coded the three pages as separate PHP pages with names survey, survey1,survey2 . what i want is make a single php file say survey which contains all info. So when i press submit the after 8 questions it should redirect to survey itself and survey should understand that next set of questions need to shown now. How can i do this?? I know its possible. I dont know how i can declare a variable and check its value. after each submit. Please let me know if i can use my same code and continue some how. Thanks for the help.
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    You haven't explained yourself clearly as I am still unsure after a couple reads. If you want to pass variables from one page to another, use sessions or hidden inputs. But your comment about declaring variables and checking its value makes me curious... How much experience have you had with php?

    Anyway, post any code you have and maybe provide a little more clear an explanation.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      And do not forget to show any code within the apppropriate code tags!
      See How to Ask a Question

      This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

      moderator

      Comment

      • Xean45
        New Member
        • Mar 2008
        • 5

        #4
        Personally, I'd use a cookie to pass the choices entered to the next pages. This would be the simplest approach, in my opinion. Or you could also write the selections to a temporary text file, but that would be more work than it's worth. Cookies I'd say.

        ~Xean

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          I second what was previously said about using the session array. Because using the $_SESSION array is the simplest and easiest way to preserve and pass data around different pages/scripts.

          Ronald

          Comment

          • learnPHP
            New Member
            • Mar 2008
            • 20

            #6
            I am sorry for not being clear. let me try and explain again
            1) I have a questionnaire which has three pHP pages survey, Survey1, survey2
            2) each php has 8 questions.
            3) now what i want to do is instead of having 3 php pages have a single page say new_survey. But at one time it should display only 8 questions. then when i continue to next page i use session variables to store the data that has been entered which is mentioned in survey1.
            4) but now since i have only 1 page how do i direct it to the second part of the code which corresponds to survey1??

            I hope i am being more clear now. I have to combine all 3 php pages into a single php page which works the sameway as i have been doing till now.

            Can some1 help?? and by the way i am almost a fresher to PHP.

            Thanks!!!

            Comment

            • TheServant
              Recognized Expert Top Contributor
              • Feb 2008
              • 1168

              #7
              How about using javascript to hide and unhide each block? That way, no page turning is needed but rather, when a user has finished the first 8, he clicks continue which will hide the first 8 and unhide the second 8 etc..

              Comment

              • learnPHP
                New Member
                • Mar 2008
                • 20

                #8
                How can i restrict a piece of HTML code to execute using JavaScript. I am not being able to do that. and also how do i use javascript variable here...since after pressing the continue button wouldnt the value of that variable change to its original value?

                Comment

                • printedgoods
                  New Member
                  • Nov 2007
                  • 9

                  #9
                  I don't know if this will help, but i just did the same thing for a customer/user update page that has a lot of forms to be filled out in ASP.

                  I used 2 pages-- header.asp and usreinfo.asp

                  In the header i used tabs to go to and fro each page, but you prbly don't need that so just look at the exanple below

                  To make the explanation simple: use the query sting to move between the pages

                  www.whatever.co m?page="1"

                  In the HTML I used the IF THEN ELSEIF statements to show the sections of forms i wanted displayed. (Like this)

                  Code:
                  <form  (do information)>
                  <table>
                  <% if request.QueryString("page") = "" then%> <!-- first page -->
                    <tr>
                      <td width="205"><div align="right">First Name</div></td>
                      <td width="10">&nbsp;</td>
                      <td width="221"><input  type="text" name="F_name" id="F_name" value="<%= userRS.fields("form") %> " />
                      </td>
                    </tr>
                    <% elseif request.QueryString("page") = "nextpage" then%> <!-- Page the next -->
                    (Step and repeat just remember to change your "page= 'variable' ")
                  
                  <%end if%>
                  </table>
                  <Button>
                  </form>
                  To submit the form use the same method the the head section only submitting the form fields for that page in the query string. You can also use it with the Java validation scripts to make sure they submit information correctly.

                  I hope this helps out. I know it is not PHP but might give you a step in the right direction. Of course i am learning as I go and consider myself a novice, so I am sure someone has a quicker way and the correct method for PHP.

                  Jason
                  Printedgoods.co m

                  Comment

                  Working...