elseif(empty($_POST Not working

Hi everyone!
I’m new to PHP and needed help from you. I have the following code that I can’t figure out why it doesn’t work on the last elseif. When load up the script, it prints input Location and “Next 1” button as expected, after selected Location it prints out Location and input Instructor with selection as expected. But after selected Instructor and click “Next 2” button, it goes back to the begin for input Location.
If I comment out the first elseif (line 19-39), it goes to the last elseif and prints out Location and (hardcoded) instructor, and input Course.

Can someone here help? Thank you!!!

The content of Instructors.txt as follow:
ID#|fName lName|email_address|course1:course2:course3
ID#|fName lName|email_address|course1:course3
ID#|fName lName|email_address|course1:course2:course4
ID#|fName lName|email_address|course2:course3:course5:course6

<?php //If we submitted the form if(empty($_POST['Location'])) { $FH = fopen("Locations.txt", "rb"); print "\n"; print "

Location:\n"; print "\n"; print "-- Select --\n"; while (!feof($FH)){ $line_of_text = fgets($FH); $line = explode('|', $line_of_text); print "$line[1]"; } fclose($FH); print "\n"; exit(); } elseif(empty($_POST['Instructor'])) { $location = ($_POST['Location']); $FH = fopen("Instructors.txt", "rb"); print "\n"; print "

Location: \n"; print "

Instructor: \n"; print "\n"; print "-- Select --\n"; while (!feof($FH)){ $line_of_text = fgets($FH); $line = explode('|', $line_of_text); if ($line[0] == "$location") { print "$line[1]\n"; } } fclose($FH); print "\n"; exit(); } elseif(empty($_POST['Course'])) { $location = ($_POST['Location']); $instructor = ($_POST['Instructor']); $FH = fopen("Instructors.txt", "rb"); print "\n"; print "

Location: \n"; print "

Instructor: \n"; print "

Course: \n"; print "\n"; print "-- Select --\n"; while (!feof($FH)){ $line_of_text = fgets($FH); $line = explode('|', $line_of_text); if ($line[1] == "Bert Vandenber") { $course = explode(':', $line[3]); for ($i=0; $i<count($course); $i++) { print "$course[$i]\n"; } } } fclose($FH); print "\n"; exit(); } ?>

problem solved. thanks!

Sponsor our Newsletter | Privacy Policy | Terms of Service