I have following code in HTML
<progress id="progressBar" value="0" max="100" style="width:250px;"></progress>
<h3 id="status">Phase 1 of 3</h3>
<form id="multiphase" onsubmit="return false">
<div id="phase1">
First Name: <input id="firstname" name="firstname"><br>
<span id="stay" name="stay">19</span>
<button onclick="processPhase1()">Continue</button>
</div>
<div id="phase2">
Gender: <select id="gender" name="gender">
<option value=""></option>
<option value="m">Male</option>
<option value="f">Female</option>
</select><br>
<button onclick="processPhase2()">Continue</button>
</div>
<div id="phase3">
Country: <select id="country" name="country">
<option value="United States">United States</option>
<option value="India">India</option>
<option value="United Kingdom">United Kingdom</option>
</select><br>
<button onclick="processPhase3()">Continue</button>
</div>
<div id="show_all_data">
First Name: <span id="display_fname"></span> <br>
Last Name: <span id="display_stay"></span> <br>
Gender: <span id="display_gender"></span> <br>
Country: <span id="display_country"></span> <br>
<button onclick="submitForm()">Submit Data</button>
</div>
</form>
and javascript
var fname, stay, gender, country;
function _(x){
return document.getElementById(x);
}
function processPhase1(){
fname = _("firstname").value;
stay = _("stay").innerHTML;
if(fname.length > 2 ){
_("phase1").style.display = "none";
_("phase2").style.display = "block";
_("progressBar").value = 33;
_("status").innerHTML = "Phase 2 of 3";
} else {
alert("Please fill in the fields");
}
}
function processPhase2(){
gender = _("gender").value;
if(gender.length > 0){
_("phase2").style.display = "none";
_("phase3").style.display = "block";
_("progressBar").value = 66;
_("status").innerHTML = "Phase 3 of 3";
} else {
alert("Please choose your gender");
}
}
function processPhase3(){
country = _("country").value;
if(country.length > 0){
_("phase3").style.display = "none";
_("show_all_data").style.display = "block";
_("display_fname").innerHTML = fname;
_("display_stay").innerHTML = stay;
_("display_gender").innerHTML = gender;
_("display_country").innerHTML = country;
_("progressBar").value = 100;
_("status").innerHTML = "Data Overview";
} else {
alert("Please choose your country");
}
}
function submitForm(){
_("multiphase").method = "post";
_("multiphase").action = "my_parser.php";
_("multiphase").submit();
}
and finally my_parser.PHP file
<?php
//if(isset($_POST['fname'])){
echo $_POST['fname']."<br>";
echo $_POST['stay']."<br>";
echo $_POST['gender']."<br>";
echo $_POST['country']."<br>";
//}
?>
As you can see i've comment out" if(isset($_POST['fname']))".with this comment i receive error " Undefined index: fname in my_parser.php and also Undefined index: stay in my_parser.php.. But when i delete that comment i dont receiove any results,just while screen..
can anyone can explain me whats wrong am i doing wrong??