Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8063063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:53:42+00:00 2026-06-05T10:53:42+00:00

I am very new to PHP programming infact its just been 3 days since

  • 0

I am very new to PHP programming infact its just been 3 days since I started so I need your help .
I am creating a form which contains 4 pages . When user clicks on Back button , for example from page 2 to page 1 all the data which he previously selected on page1 should be be present there so that he need not fill it again .
Could you please help me with this by posting the code .

Here is the sample code

page1.php

<?php
session_start();
$session=session_id();
$_SESSION['session']=$session;

    ?>
    <html>
    <body>
    <form action="oopssurvey.php" method="post">
    Where do you work?<br/>
    <Input type ="radio" name="location" value="USA" <?php if($_SESSION['location']    == 'USA') echo "checked='checked'" ?>/>In the United states<br/>
    <Input type ="radio" name="location" value="India" <?php if($_SESSION['location'] == 'India') echo "checked='checked'" ?>/>Outside of the United states<br/>

    <input name="Operation1" type="submit" value="saveandresume" />
    <input name="Operation2" type="submit" value="next" />

    </form>
    </body>
    </html>

page2.php

<?php
session_start();

if($_SESSION['session']==$session)
{
$location=$_SESSION['location'];
}
else
{
$_SESSION['location'] = $_POST['location'];
}
?>

<html>

<body>

<form action="oopssurvey.php" method="post">

In my work group, we are actively involved in making our work processes more effective and efficient (simpler, faster, etc.) using ACE.<br/>
<Input type ="radio" name="effective" value="Agree"/>Agree<br/>
<Input type ="radio" name="effective" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="effective" value="disagree"/>Disagree<br/>

I have received the training I need to understand and implement ACE in my work group.<br/>
<Input type ="radio" name="training" value="Agree"/>Agree<br/>
<Input type ="radio" name="training" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="training" value="disagree"/>Disagree<br/>

All employees at the company are treated fairly regardless of differences.<br/>
<Input type ="radio" name="treated" value="Agree"/>Agree<br/>
<Input type ="radio" name="treated" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="treated" value="disagree"/>Disagree<br/>

Sufficient effort is made to get the opinions and thoughts of the people who work here.<br/>
<Input type ="radio" name="effort" value="Agree"/>Agree<br/>
<Input type ="radio" name="effort" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="effort" value="disagree"/>Disagree<br/>

<input name="Operation3" type="submit" value="saveandresume" />
<input name="Operation4" type="submit" value="next" />
<input name="Operation5" type="submit" value="back" />

</form>

</body>

</html>

page3.php

//somecode//

Survey.php

<?php
session_start();
include 'classperson.php';


if($_POST['Operation1'])
{
$_SESSION['location'] = $location;
$_SESSION['location'] = $_POST['location'];
echo "Please save the link inorder to continue your survey http://bonnie/~jnagesh/SampleSurvey/OOPS/oopspage2.php";
}

else if($_POST['Operation2'])
{
$_SESSION['location'] = $location;
$_SESSION['location'] = $_POST['location'];
include "oopspage2.php";
}


elseif($_POST['Operation3'])

{
$_SESSION['effective'] = $effective;
$_SESSION['effective'] = $_POST['effective'];
$_SESSION['training'] = $training;
$_SESSION['training'] = $_POST['training'];
$_SESSION['treated'] = $treated;
$_SESSION['treated'] = $_POST['treated'];
$_SESSION['effort'] = $effort;
$_SESSION['effort'] = $_POST['effort'];
echo "Please save the link inorder to continue your survey later http://bonnie/~jnagesh/SampleSurvey/NextandBackButtons/page3.php";

}

elseif($_POST['Operation4'])
{
$_SESSION['effective'] = $effective;
$_SESSION['effective'] = $_POST['effective'];
$_SESSION['training'] = $training;
$_SESSION['training'] = $_POST['training'];
$_SESSION['treated'] = $treated;
$_SESSION['treated'] = $_POST['treated'];
$_SESSION['effort'] = $effort;
$_SESSION['effort'] = $_POST['effort'];
include "oopspage3.php";
}

elseif($_POST['Operation5'])     /* THE PROBLEM LIES IN THIS CODE FOR BACK BUTTON*/
{
$location = $_POST['location'];
$_SESSION['location'] = $location;
<html> 
<body> 
<form action="1.php" method="post"> /*oBVIOUSLY i WONT BE ALLOWED TO DECLARE <HTML> INSIDE PHP*/
<input type="submit" value="back"/>
</form> 
</body> 
}

.
.
.
.
.
.
.
.
?>

could you please help me how to implement the back button .
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:53:45+00:00Added an answer on June 5, 2026 at 10:53 am

    Try this i hope its work for you

    Page1.php

    <?php
    @session_start();
    //$session=session_id();
    //$_SESSION['session']=$session;
    //print_r($_SESSION);
    ?>
    <html>
    <body>
    <form action="oopssurvey.php" method="post">
      Where do you work?<br/>
      <Input type ="radio" name="location" value="USA" <?php if(isset($_SESSION['location'])    == 'USA') echo "checked='checked'" ?>/>
      In the United states<br/>
      <Input type ="radio" name="location" value="India" <?php if(isset($_SESSION['location']) == 'India') echo "checked='checked'" ?>/>
      Outside of the United states<br/>
      <input name="Operation1" type="submit" value="saveandresume" />
      <input name="Operation2" type="submit" value="next" />
    </form>
    </body>
    </html>
    

    Page2.php

    <html>
    
    <body>
    <form action="oopssurvey.php" method="post">
      In my work group, we are actively involved in making our work processes more effective and efficient (simpler, faster, etc.) using ACE.<br/>
      <Input type ="radio" name="effective" value="Agree" <?php if(isset($_SESSION['effective'])    == 'Agree') echo "checked='checked'" ?>/>
      Agree<br/>
      <Input type ="radio" name="effective" value="Agreenordisagree" <?php if(isset($_SESSION['effective'])    == 'Agreenordisagree') echo "checked='checked'" ?>/>
      Neither Agree nor Disagree<br/>
      <Input type ="radio" name="effective" value="disagree" <?php if(isset($_SESSION['effective'])    == 'disagree') echo "checked='checked'" ?>/>
      Disagree<br/>
      I have received the training I need to understand and implement ACE in my work group.<br/>
      <Input type ="radio" name="training" value="Agree" <?php if(isset($_SESSION['training'])    == 'Agree') echo "checked='checked'" ?>/>
      Agree<br/>
      <Input type ="radio" name="training" value="Agreenordisagree" <?php if(isset($_SESSION['training'])    == 'Agreenordisagree') echo "checked='checked'" ?>/>
      Neither Agree nor Disagree<br/>
      <Input type ="radio" name="training" value="disagree" <?php if(isset($_SESSION['training'])    == 'disagree') echo "checked='checked'" ?>/>
      Disagree<br/>
      All employees at the company are treated fairly regardless of differences.<br/>
      <Input type ="radio" name="treated" value="Agree" <?php if(isset($_SESSION['treated'])    == 'Agree') echo "checked='checked'" ?>/>
      Agree<br/>
      <Input type ="radio" name="treated" value="Agreenordisagree" <?php if(isset($_SESSION['treated'])    == 'Agreenordisagree') echo "checked='checked'" ?>/>
      Neither Agree nor Disagree<br/>
      <Input type ="radio" name="treated" value="disagree" <?php if(isset($_SESSION['treated'])    == 'disagree') echo "checked='checked'" ?>/>
      Disagree<br/>
      Sufficient effort is made to get the opinions and thoughts of the people who work here.<br/>
      <Input type ="radio" name="effort" value="Agree" <?php if(isset($_SESSION['effort'])    == 'Agree') echo "checked='checked'" ?>/>
      Agree<br/>
      <Input type ="radio" name="effort" value="Agreenordisagree" <?php if(isset($_SESSION['effort'])    == 'Agreenordisagree') echo "checked='checked'" ?>/>
      Neither Agree nor Disagree<br/>
      <Input type ="radio" name="effort" value="disagree" <?php if(isset($_SESSION['effort'])    == 'disagree') echo "checked='checked'" ?>/>
      Disagree<br/>
      <input name="Operation3" type="submit" value="saveandresume" />
      <input name="Operation4" type="submit" value="next" />
      <input name="Operation1" type="submit" value="back" />
    </form>
    </body>
    </html>
    

    Page3.php Or oopssurvey.php

    <?php
    @session_start();
    //include 'classperson.php';
    
    if(isset($_POST['Operation1']))
    {
        if($_POST['Operation1'] == 'saveandresume'){
            $_SESSION['location'] = $_POST['location'];
            echo "Please save the link inorder to continue your survey http://bonnie/~jnagesh/SampleSurvey/OOPS/oopspage2.php";
        }else if($_POST['Operation1'] == 'back') {
            include "page1.php";            
        }
    }
    
    else if(isset($_POST['Operation2'])){
        include "page2.php";
    }
    
    
    elseif(isset($_POST['Operation3'])){
    
    $_SESSION['effective'] = $_POST['effective'];
    $_SESSION['training'] = $_POST['training'];
    $_SESSION['treated'] = $_POST['treated'];
    $_SESSION['effort'] = $_POST['effort'];
    echo "Please save the link inorder to continue your survey later http://bonnie/~jnagesh/SampleSurvey/NextandBackButtons/page3.php";
    }
    
    elseif(isset($_POST['Operation4']))
    {
        if($_POST['Operation4'] == 'next'){
            echo "welcome to form3";    
            //include "oopspage3.php";
        }else{
        /*$_SESSION['effective'] = $effective;
        $_SESSION['effective'] = $_POST['effective'];
        $_SESSION['training'] = $training;
        $_SESSION['training'] = $_POST['training'];
        $_SESSION['treated'] = $treated;
        $_SESSION['treated'] = $_POST['treated'];
        $_SESSION['effort'] = $effort;
        $_SESSION['effort'] = $_POST['effort'];*/   
    
        }
    
    
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new in programming. I'm writing a PHP application that need to execute
Very new to PHP/programming in general, and I've been trying to run a PHP
Hey I am very new to Web Programming. I have been learning PHP from
I am very new to programming in general, while reading about PHP I saw
I'm very new to PHP; and am doing a few sample projects to help
I am very new to programming, and have been banging my head against the
I'm very new to PHP, and just customizing my homepage. This is the main
i am very new to Programming and i am just reading the documents. For
I'm very new to php/MySQL and I'm having a bit of trouble. Help would
I am very new to PHP programming and dont know the exact syntax of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.