我有兩個頁面。一個選擇框和發送按鈕。當用戶從選擇框中選擇他們的選項並點擊發送時,它將把它們帶到輸出其選擇的第二頁面。無法使用PHP從一個頁面獲取信息到另一個頁面
date_change.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<?php
$day = array(range(1,31));
$month = array(range(1,12));
$year = array(range(2011,2020));
?>
<form action="test.php" method="post">
Day:
<select >
<?php foreach($day[0]++ as $key => $value) { ?>
<option value="<?php echo $key ?>" name="day"><?php echo $value ?></option>
<?php }?>
</select>
<br>
Month:
<select>
<?php foreach($month[0]++ as $key => $value) { ?>
<option value="<?php echo $key ?>" name="month"><?php echo $value ?></option>
<?php }?>
</select>
<br>
Year:
<select>
<?php foreach($year[0]++ as $key => $value) { ?>
<option value="<?php echo $key ?>" name="year"><?php echo $value ?></option>
<?php }?>
</select>
<input type='submit' value='send' name='send' />
</form>
</body>
</html>
一旦用戶使得他們的選擇並點擊發送需要他們的test.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
Date Selected: <?php echo $_POST["day"];echo $_POST["month"];echo $_POST["year"]; ?>
</body>
</html>
然而,即使它進入test.php的頁面它不顯示用戶選擇的內容。任何幫助?
我在哪裏錯了?
一分鐘內五個相同的答案。尼斯:D –
@Stephan:是的,太棒了! –
你是否設法解決了這個問題? –