I am trying to store data in $_SESSION
variables so I can use it in other parts of the form.
I have an input for team name which I need to use within a drop down a couple of steps down the form, the team name come from the user input only.
Im struggling to pass this data throughout the form and then post it at the end.
The session is being set in header.php
<?php
if(!empty($_POST)) {
$_SESSION['dashboardName'] = $_POST['dashboardName'];
$_SESSION['teamName'] = $_POST['teamName'];
$_SESSION['firstName'] = $_POST['firstName'];
$_SESSION['lastName'] = $_POST['lastName'];
$_SESSION['memberTeam'] = $_POST['memberTeam'];
$_SESSION['stenData'] = $_POST['stenData'];
$_SESSION['score_1'] = $_POST['score_1'];
$_SESSION['score_2'] = $_POST['score_2'];
$_SESSION['score_3'] = $_POST['score_3'];
$_SESSION['score_4'] = $_POST['score_4'];
$_SESSION['score_5'] = $_POST['score_5'];
$_SESSION['score_6'] = $_POST['score_6'];
$_SESSION['score_7'] = $_POST['score_7'];
$_SESSION['score_8'] = $_POST['score_8'];
}
?>
<form action="" method="POST">
<!-- STEP :: 1 -->
<div class="step-one">
<h1>STEP 1</h1>
<input type="text" name="dashboardName" required placeholder="Dashboard Name" value="<?php echo $_SESSION['dashboardName']; ?>">
<button class="step-one-next">Next</button>
</div>
<!-- STEP :: 2 -->
<div class="step-two">
<h1>STEP 2</h1>
<input type="text" name="teamName" placeholder="Team name" required value="<?php echo $_SESSION['teamName']; ?>">
<button class="step-two-previous">Previous</button>
<button class="step-two-next">Next</button>
</div>
<!-- STEP :: 3 -->
<div class="step-three">
<h1>STEP 3</h1>
<input type="text" name="firstName" placeholder="First Name" required value="<?php echo $_SESSION['firstName']; ?>">
<input type="text" name="lastName" placeholder="Last Name" required value="<?php echo $_SESSION['lastName']; ?>">
<button class="step-three-previous">Previous</button>
<button class="step-three-next">Next</button>
</div>
<!-- STEP :: 4 -->
<div class="step-four">
<h1>STEP 4</h1>
<select name="memberTeam">
<option><?php echo $_SESSION['teamName']; ?></option>
</select>
<button class="step-four-previous">Previous</button>
<button class="step-four-next">Next</button>
</div>
<!-- STEP :: 5 -->
<div class="step-five">
<h1>STEP 5</h1>
<textarea name="stenData" placeholder="Paste Sten Data..." required><?php echo $_SESSION['stenData']; ?></textarea>
<button class="step-five-previous">Previous</button>
<button class="step-five-next">Next</button>
</div>
<!-- STEP :: 6 -->
<div class="step-six">
<h1>STEP 6</h1>
<select name="score_1">
<option selected="selected"><?php echo $_SESSION['score_1']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_2">
<option selected="selected"><?php echo $_SESSION['score_2']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_3">
<option selected="selected"><?php echo $_SESSION['score_3']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_4">
<option selected="selected"><?php echo $_SESSION['score_4']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_5">
<option selected="selected"><?php echo $_SESSION['score_5']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_6">
<option selected="selected"><?php echo $_SESSION['score_6']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_7">
<option selected="selected"><?php echo $_SESSION['score_7']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_8">
<option selected="selected"><?php echo $_SESSION['score_8']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button class="step-six-previous">Previous</button>
<button class="step-six-next">Next</button>
</div>
<!-- STEP :: 7 -->
<div class="step-seven">
<h1>STEP 7</h1>
<p><?php echo $_SESSION['dashboardName']; ?></p>
<button class="step-seven-previous">Previous</button>
<input type="submit" name="test" value="Submit">
</div>
</form>
<script>
$(".step-one-next").click(function(){
$(".step-one").hide();
$(".step-two").show();
});
$(".step-two-previous").click(function(){
$(".step-two").hide();
$(".step-one").show();
});
$(".step-two-next").click(function(){
$(".step-two").hide();
$(".step-three").show();
});
$(".step-three-previous").click(function(){
$(".step-three").hide();
$(".step-two").show();
});
$(".step-three-next").click(function(){
$(".step-three").hide();
$(".step-four").show();
});
$(".step-four-previous").click(function(){
$(".step-four").hide();
$(".step-three").show();
});
$(".step-four-next").click(function(){
$(".step-four").hide();
$(".step-five").show();
});
$(".step-five-previous").click(function(){
$(".step-five").hide();
$(".step-four").show();
});
$(".step-five-next").click(function(){
$(".step-five").hide();
$(".step-six").show();
});
$(".step-six-previous").click(function(){
$(".step-six").hide();
$(".step-five").show();
});
$(".step-six-next").click(function(){
$(".step-six").hide();
$(".step-seven").show();
});
$(".step-seven-previous").click(function(){
$(".step-seven").hide();
$(".step-six").show();
});
</script>
So the end goal is to input the inputs at each stage, name the team and then the team names be available in the drop down on the memberTeam
<select>