Hi The isset function has seemed to have stopped working in a few of my scripts. The example below shows it used in a form when the form is posted. The global variables used within the function seem to be blank (almost like the isset function clears any values they have). I have tried echoeing out the variables before the function and the correct values are printed to the screen. The code is as follows: <select name = "add_student" id = "add_student"> <?php while ($row = mysql_fetch_assoc($rst)) { $individual = $row['PU_Surname'] . " " . $row['PU_Forename'] . " - " . $row['PU_AdNo']; ?> <option value="<?php echo $row['PU_AdNo']; ?>"><?php echo $individual; ?></option> <?php } ?> </select> </td> <td> </td> <td> <input type="submit" name="Submit" value="Submit" onclick = 'javascript: return confirm("Are you sure you want to add this student to this class?")' /> <input type = 'hidden' name = 'submitted' value = 'true'> </td> </tr> </table> </form> <?php $ad_no = $_POST['add_student']; if (isset($_POST['add_student'])) { echo $row['PU_AdNo']; $sql3 = "INSERT INTO ClassStudent ( CS_CL_ClassName , CS_PU_AdNo , CS_CL_SubjectCode , CS_PU_Year, CS_GT ) VALUES ('" . $current_class . "', '" . $ad_no . "', '" . $subjectcode . "', '" . $current_year . "', '" . $current_year . "')"; include("../includes/php/connect3.php"); } ?> HTML: The INSERT statement does work, but the $current_class, $subjectcode and $current_year variables are blank when they should contain values. Any help with this issue would be greatly appreciated.
It seems you have register_globals turned OFF (and it's good). Instead of using autoglobals ($current_class) use values from $_POST ($_POST('current_class']).
You are assigning $ad_no to the $_POST before you check if that $_POST is set, change that around, check if that post isset first then assign it. Also, what are you using in your main form tag, $_SERVER['PHP_SELF'] ? Also, what does the include do at the very bottom? <select name = "add_student" id = "add_student"> <?php while ($row = mysql_fetch_assoc($rst)) { $individual = $row['PU_Surname'] . " " . $row['PU_Forename'] . " - " . $row['PU_AdNo']; ?> <option value="<?php echo $row['PU_AdNo']; ?>"><?php echo $individual; ?></option> <?php } ?> </select> </td> <td> </td> <td> <input type="submit" name="Submit" value="Submit" onclick = 'javascript: return confirm("Are you sure you want to add this student to this class?")' /> <input type = 'hidden' name = 'submitted' value = 'true'> </td> </tr> </table> </form> <?php $ad_no = ''; if (isset($_POST['add_student'])) { $ad_no = $_POST['add_student']; echo $row['PU_AdNo']; $sql3 = "INSERT INTO ClassStudent ( CS_CL_ClassName , CS_PU_AdNo , CS_CL_SubjectCode , CS_PU_Year, CS_GT ) VALUES ('" . $current_class . "', '" . $ad_no . "', '" . $subjectcode . "', '" . $current_year . "', '" . $current_year . "')"; include("../includes/php/connect3.php"); } ?> Code (markup):