<?php
session_start();
?>
<?php
if(isset($_POST['makeFile'])){
$fileName = $_SESSION['firstname']."_".$_SESSION['lastname'];
$newFileName = "users/".$fileName.".txt";
$file = fopen($newFileName, "w");
fwrite($file, $_SESSION['firstname'] . "\n");
fwrite($file, $_SESSION['lastname'] . "\n");
fwrite($file, $_SESSION['age'] . "\n");
fwrite($file, $_SESSION['streetaddrs'] . "\n");
fwrite($file, $_SESSION['postalcode'] . "\n");
fclose($file);
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Success</title>
</head>
<body>
<p>First Name: <?php echo $_SESSION['firstname']; ?></p>
<p>Last Name: <?php echo $_SESSION['lastname']; ?></p>
<p>Age: <?php echo $_SESSION['age']; ?></p>
<p>Street Address: <?php echo $_SESSION['streetaddrs']; ?></p>
<p>Postal Code: <?php echo $_SESSION['postalcode']; ?></p>
<form method="POST">
<button type="submit" name="makeFile">SAVE DATA</button>
</form>
</body>
</html>
在填写表单信息后,提交表单并重定向到此页面。问题是在这个屏幕上saveData.php没有显示内容。有什么帮助吗?