我正在構建一個簡單的工具,它將根據HTML表單輸入組裝一個字符串。來自HTML表單的某些變量沒有得到迴應
但是,兩個變量沒有按預期拉入字符串。
下面是HTML表單:
<form action="stringmaker.php" method="post">
<label for="subline">Subject line:</label>
<input type="text" id="subline" name="subline" size="30" /><br /><br />
<label for="emailtype">Email Type</label>
<select name="emailtype">
<option value="advocacy" selected>Advocacy</option>
<option value="fundraising">Fundraising</option>
<option value="newsletter">Newsletter</option>
<option value="event">Event</option>
<option value="cultivation">Cultivation</option>
</select><br /><br />
<label for="campaign">Campaign</label>
<select name="campaign">
<option value="campaign1" selected>Campaign 1</option>
<option value="campaign2" selected>Campaign 2</option>
<option value="campaign3" selected>Campaign 3</option>
<option value="campaign4" selected>Campaign 3</option>
</select>
<h3>Audience Information</h3>
<label for="audiencetype">Audience Type</label>
<select name="audiencetype">
<option value="noaudiencetype" selected>None</option>
<option value="interestgroup">Interest Group</option>
<option value="donors">Donors</option>
<option value="actiontakers">Action-Takers</option>
</select><br /><br />
<label for="geo">Audience Geography</label>
<select name="geo">
<option value="national" selected>National</option>
<option value="state">State</option>
<option value="district">District</option>
<option value="city">City</option>
</select><br /><br />
<label for="statename">State</label>
<select name="statename">
<option value="ak" selected>Alaska</option>
<option value="al">Alabama</option>
<option value="az">Arizona</option>
<option value="dc">Washington, D.C.</option>
</select><br /><br />
<input type="submit" value="Go" name="submit" />
這裏是PHP:
<?php
$subline = $_POST['subline'];
$emailtype = $_POST['emailtype'];
$campaign = $_POST['campaign'];
$audiencetype = $_POST['audiencetype'];
$geo = $_POST['geo'];
$statename = $_POST['statename'];
echo "<p>Here's your string!<br>";
echo $subline,"|",$emailtype,"|",$campaign,"|",$audiencetype,"|",$geo,"|",$statename;
?>
輸出缺失頭($subline
)和第五($geo
)變量,我可以」弄清楚與那些有什麼不同。
感謝您的幫助。
'print_r($ _ POST);'告訴我們結果 – 2014-09-04 02:45:25
嘗試'echo $ subline。「|」。$ emailtype。「|」。$ campaign。「|」。$ audiencetype。「|」。$ geo。「|」。$ statename;'點是連接的,而不是逗號。另外,您的問題的代碼缺少結尾''標記。 – 2014-09-04 02:49:40
我認爲@ Fred-ii-是正確的 – kimbarcelona 2014-09-04 02:50:09