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

  • SEARCH
  • Home
  • 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 7756403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:48:51+00:00 2026-06-01T12:48:51+00:00

I am fairly new to PHP, but have applied my previous knowledge of programming,

  • 0

I am fairly new to PHP, but have applied my previous knowledge of programming, along with internet searches to get me this far.

I’m trying to make a step by step form entry, where the criteria entered on a page by page basis and only updates the database once the entire form is filled out. I plan on embellishing the form further after I get the basic functionality working on it.

As of the moment the name variable is getting populated, however after submission of the second stage it loops back to the first stage of entry, although the URL updates to stage 3, because of this the information can not get parsed to the database.

I am using PHP v5, I have seen resolutions to this issue using AJAX, but I am not using it in this instance.

Thank you for your time and efforts.

 <?php 

$stage = $_GET['stage'];

//Starting on form 1
$stage = 'one';

//get form details
$name = $_POST['name'];
$surname = $_POST['surname'];

/* ---- Checking if you submitted and if you were on form one THEN set the form the stage2 in order to display the next form ---- */
if (isset($_POST['submitStage1']) && $stage == 'one') {
$stage = 'two';
echo "checking sumbit from stage1";
}
if (isset($_POST['submitStage2']) && $stage == 'two') {
$stage = 'three';
echo "checking submit from stage2 going to 3";
} 

if (isset($_POST['submitStage3']) && $stage == 'three') {
    $stage = 'three';
echo "Adding to database";

}
?>



<?php 
if ($stage == 'one') {
echo $stage;
?>

<div style="width:100%; margin-bottom: 20px;"> Step_001</div>

<form method="post" action="addperson.php?stage=2">
<input name="name" type="text" />
<input name="submitStage1" type="submit" />
</form>

<?php
}
?>





<?php
if ($stage == 'two') {
echo $stage;
?> 

<div style="width:100%; margin-bottom: 20px;"> Step_002</div>

<form method="post" action="addperson.php?stage=3">

<input name="surname" type="text" />
<input name="submitStage2" type="submit" />

</form>

<?php
}
?>




<?php if ($stage == 'three') { echo $stage;

echo "Adding to database";


    $name = mysql_real_escape_string($_POST['name']);   $surname = mysql_real_escape_string($_POST['surname']);     

// Add this product into the database now   
$sql = mysql_query("INSERT INTO testpeople (name, surname) 
        VALUES('$name','$surname')") or die (mysql_error());

    exit(); } ?>
  • 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-01T12:48:52+00:00Added an answer on June 1, 2026 at 12:48 pm

    Remove

    $stage = 'one' ;
    

    Replace

    $stage = $_GET['stage'];
    

    With

    $stage = isset($_GET['stage']) ? $_GET['stage'] : "one" ;
    

    Thanks

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have plenty of experience with this in PHP, but am fairly new to
This might be a simple question, but I'm fairly new to PHP and am
I am fairly new to php but I have an index file in my
I'm fairly new to PHP and have built a medium sized website using standard
I am fairly new to PHP and Codeigniter so im sure this will be
I'm fairly new to user authentication, but have built some standard user authentication processes
i'll try my best to explain the situation but i'm fairly new to php
fairly new to Objective-C and iOS development (coming from PHP) and I have a
I am fairly new to php. I have a text file on my computer
I am new to cakePHP and fairly new to PHP as well, I have

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.