Ich baue einen Stammbaum für eine Klassenzuweisung und ich muss Variablen aus einem HTML-Formular in eine PHP-Datei für dieses Familienmitglied übergeben, abhängig davon, wessen Informationen aktualisiert werden. Ich brauche die Formularvariablen, um in die php-Datei für Vater, Mutter, Ehefrau usw. übergehen zu können.HTML-Variable an mehrere PHP-Dateien übergeben
HTML Datei
<form action="handle_family.php" method="post">
<p>Family Member: <select name="name">
<option value="david">David</option>
<option value="linda">Linda</option>
<option value="cayla">Cayla</option>
<option value="sophie">Sophie</option>
<option value="sawyer">Sawyer</option>
</select></p>
<p>Relationship: <select name="relationship">
<option value="father">Father</option>
<option value="mother">Mother</option>
<option value="wife">Wife</option>
<option value="son">Son</option>
<option value="daughter">Daughter</option>
</select></p>
<p>Interests: <input type="text" name="interests" size="60" /></p>
<p>History: <input type="text" name="history" size="60" /></p>
<p>Occupation: <input type="text" name="occupation" size="60" /></p>
<input type="submit" name="submit" value="Update Page" />
</form>
</div>
handle_family.php
<?php // Script 6.2 - handle_reg.php
ini_set ('display_errors', 1);
error_reporting (E_ALL | E_STRICT);
$okay= TRUE;
$relationship= $_POST['relationship'];
$interests= $_POST['interests'];
$history= $_POST['history'];
$occupation= $_POST['occupation'];
$name= $_POST['name'];
if($name == 'david')
{
session_start();
$_SESSION[$father_relationship] = $relationship;
$_SESSION[$father_interests] = $interests;
$_SESSION[$father_occupation] = $occupation;
$_SESSION[$father_name] = $name;
$_SESSION[$father_history] = $history;
include 'david.php';
exit();
}
david.php
<?php // david.php
// Define Variables
$father_name = $_SESSION[$father_name];
$father_relationship = $_SESSION[$father_relationship];
$father_interests = $_SESSION[$father_interests];
$father_history = $_SESSION[$father_history];
$father_occupation = $_SESSION[$father_occupation];
//print father's information
print"<h3>Relationship to Chris</h3>
<p>$father_relationship</p>
<h3>History</h3>
<p>$father_history</p>
<h3>Occupation</h3>
<p>$father_occupation</p>
<h3>Interests</h3>
<p>$father_interests</p>";
?>