我已經設置了這段代碼,我想要做的是使用會話從$ _POST [$ field]輸出數據,這樣它將被保存,因爲我還有另一個頁面我想在成功註冊後從POST中保存姓名和家庭姓名。使用會話輸出來自POST的值
<body>
<?php
if (isset($_POST["vorname"]) && isset($_POST["nachname"]) && isset($_POST["geburtstag"])&&
isset($_POST["email"]) && isset($_POST["telefon"]) && isset($_POST["adresse"]))
$formular = array('vorname','nachname','geburtstag','email','telefon','adresse');
if (isset($_SESSION['login'])) {
foreach($formular as $field) {
$_SESSION['login'][$field]=$_POST[$field];
print_r($_SESSION['login'][$_POST[$field]] . '<br><br>');
}
}
?>
<div class="div">
<form action="login.php" method="post">
<div>Vorname </div><input type="text" name="vorname" required>
<span class="error"><?php echo $vornameErr;?></span>
<div>Nachname </div><input type="text" name="nachname" required>
<span class="error"><?php echo $nachnameErr;?></span>
<div>Geburtstag</div><input type="text" name="geburtstag" required>
<span class="error"><?php echo $geburtstagErr;?></span>
<div>Email </div><input type="Email" name="email" required>
<span class="error"><?php echo $emailErr;?></span>
<div>Telefon </div><input type="text" name="telefon" required>
<span class="error"><?php echo $telefonErr;?></span>
<div>Adresse </div><input type="text" name="adresse" required>
<span class="error"><?php echo $adresseErr;?></span><br>
<button type="submit">Submit</button>
</form>
</div>
<br>
<a href="kunden.php">kunden</a>
</body>
</html>
And this is the other page that i want to save the name and family name in to it using session
<?php
$a=array(
array('mousa','123'),
array('',''));
if(isset($_POST["name"]) && isset($_POST["password"]))
if(in_array(array($_POST["name"],$_POST["password"]),$a)){
header('Location:login.php');
}
if (isset($_SESSION['login'])) {
print_r($_SESSION['login'][$_POST["vorname"]]);
}
?>
你有沒有使用session_start地方? http://php.net/manual/en/function.session-start.php – Peter
你的問題是什麼?你開始會議嗎? – user1844933
是的,我在這兩個頁面都做了 – MOS