php - How do I post information from a <form> and get information into the form from that also needs to be posted into the same database? -


i'm making form puts student information student table. part of information requires foreign key parent_guardian_id parents table . i'd offer parents' names choice select or dropdown input foreign key. seems need , post @ same time? need @ least 2 other pages. insight.

//check student first name: if (empty($_post['student_first_name'])) {     $errors[] = "please enter student\'s first name."; } else {     $student_first_name = mysqli_real_escape_string($dbc,($_post['student_first_name']));      } if (empty($errors)){//if requirements met:              $query="insert student (student_first_name, student_last_name,             student_street, student_city, student_zip, student_phone,             student_email,  parent_guardian_id)         values ('$student_first_name', '$student_last_name',             '$student_street', '$student_city', '$student_zip', '$student_phone',             '$student_email', '$parent_guardian_id')";     $result=mysqli_query($dbc,$query);      if ($result){         echo "<center><p><b>a new student has been added.</b></p><br/>";          echo "<center><a href=studentadd.php>show students</a> </center>";          exit();     } else {       $errors[] = "<p>the record not added due system error. </p>";       $errors[] = mysqli_error($dbc) . "</p>";      } } }  mysqli_close($dbc);}  ?> <form action="studentadd.php" method="post"> <p>first name: <input type="text" name="student_first_name" size="50"     value=    "<?php echo $_post['student_first_name']; ?>"/><p><br /> <p>last name: <input type="text" name="student_last_name" size="50" value=    "<?php echo $_post['student_last_name']; ?>" /><p><br /> <p>street address: <input type="text" name="student_street" size="50" value=    "<?php echo $_post['student_street']; ?>" /><p><br /> <p>city: <input type="text" name="student_city" size="50" value=    "<?php echo $_post['student_city']; ?>"/><p><br /> <p>state: <input type="text" name="student_state" size="50" value=    "<?php echo $_post['student_state']; ?>"/><p><br /> <p>zip: <input type="text" name="student_zip" size="50" value=    "<?php echo $_post['student_zip']; ?>"/><p><br /> <p>phone: <input type="text" name="student_phone" size="50" value=    "<?php echo $_post['student_phone']; ?>"/><p><br /> <p>email address: <input type="text" name="student_email" size="50" value=    "<?php echo $_post['student_email']; ?>"/><p><br /></form> <p>parent/guardian: <select name="parent_guardian"          id="parent_guardian" size="20"      value="<?php echo $row['mother_guardian_first_name'] . "          , " . $row['mother_guardian_last_name'] . "         , " . $row['father_guardinan_first_name'] . "         , " . $row['father_guardian_last_name'];         $_post['parent_guardian_id']; ?>"/>name goes here</select><p><br /> <input type="submit" name="submit" value="submit" /> <input type="reset" name="reset" value="reset" /> <input type="hidden" name="submitted" value="true" /></p> </form>  <?php //include footer include ("footer.php");  ?> 


Popular posts from this blog