好的,所以我有一個我正在嘗試創建的網站的表單。我試圖將來自HTML的用戶輸入存儲到字符串值中以顯示在PHP中。麻煩的是,當我輸入數字值時,我無法識別PHP。這適用於「單選按鈕」類型輸入,但不適用於純文本。我已經包含了該網站的兩個頁面的代碼。 塔設計中心 - 在這裏建立自己的塔! 沒有註冊爲數組中的字符串的數字
<body>
<h1 style="font-family:impact; font-size:72; color:silver;">Tower Design Centre</h1>
<p style="font-family:courier; font-size:22; color:blue;">Build your own tower here!</p>
<p style="font-family:arial; font-size:12; color:black;"> Welcome to Tower Builder! Please select shapes and dimensions for the different parts of your tower.</p>
<form action="testfile_post.php" method="post" target="_blank" accept-charset="UTF-8">
Select pillar base shape:<br>
<input type="radio" name="tBase" value="Circle" checked>Circle<br>
<input type="radio" name="tBase" value="Triangle" checked>Triangle<br>
<input type="radio" name="tBase" value="Rectangle" checked>Rectangle<br>
<input type="radio" name="tBase" value="Pentagon" checked>Pentagon<br>
<input type="radio" name="tBase" value="Hexagon" checked>Hexagon<br>
<input type="radio" name="tBase" value="Heptagon" checked>Heptagon<br>
<input type="radio" name="tBase" value="Octagon" checked>Octagon<br>
<!--Set variable tBase equal to user's option. -->
<fieldset> <!-- Use height/width to make fieldset border smaller in order to fit picture of tower being built.-->
<legend>Pillar dimensions:</legend>
Height:<br>
<input type="text" name="tHeight"><br>
<!-- User must input height option. Text should only be positive integers greater than zero. Set variable tHeight equal to user's input. Must comply with ratios.-->
Width:<br>
<input type="text" name="tWidth"><br>
<!-- Same constraints as height apply. Set variable tWidth equal to user's input.-->
Depth:<br>
<input type="text" name="tDepth"><br>
<!-- Same constraints as height and width. Set variable tDepth equal to user's input.-->
Slant:<br>
<input type="text" name="tSlant"><br>
<!--Set variable tSlant equal to user input. tSlant cannot exceed -45 or 45. If it does, throw error message and do not allow user to continue.
Neg. and pos. integers, as well as zero, may be used. If tSlant >= 35 or <= -35, throw Leaning Tower communication.-->
</fieldset>
Select pod shape:<br>
<input type="radio" name="pShape" value="Circle" checked>Circle<br>
<input type="radio" name="pShape" value="Triangle" checked>Triangle<br>
<input type="radio" name="pShape" value="Rectangle" checked>Rectangle<br>
<input type="radio" name="pShape" value="Pentagon" checked>Pentagon<br>
<input type="radio" name="pShape" value="Hexagon" checked>Hexagon<br>
<input type="radio" name="pShape" value="Heptagon" checked>Heptagon<br>
<input type="radio" name="pShape" value="Octagon" checked>Octagon<br>
<!-- Set variable pShape equal to user's option. -->
<fieldset> <!-- Use height/width to make fieldset border smaller in order to fit picture of tower being built.-->
<legend>Pod dimensions:</legend>
Height:<br>
<input type="text" name="pHeight"><br>
<!--Text should only be positive integers greater than zero. Set variable pHeight equal to user's input.-->
Width:<br>
<input type="text" name="pWidth"><br>
<!-- Same constraints as height apply. Set variable pWidth equal to user's input.-->
Depth:<br>
<input type="text" name="pDepth"><br>
<!-- Same constraints as height and width. Set variable pDepth equal to user's input.-->
</fieldset>
<fieldset>
<legend>Pod placement:</legend>
<input type="text" name="pPlace1"><br>
<!--Set variable pPlace1 equal to user's input. -->
out of<br>
<input type="text" name="pPlace2"><br>
<!--Set variable pPlace2 equal to user's input.-->
</fieldset>
<!-- Do not let pPlace1 exceed pPlace2.-->
Select spindle base shape:<br>
<input type="radio" name="sShape" value="Circle" checked>Circle<br>
<input type="radio" name="sShape" value="Triangle" checked>Triangle<br>
<input type="radio" name="sShape" value="Rectangle" checked>Rectangle<br>
<input type="radio" name="sShape" value="Pentagon" checked>Pentagon<br>
<input type="radio" name="sShape" value="Hexagon" checked>Hexagon<br>
<input type="radio" name="sShape" value="Heptagon" checked>Heptagon<br>
<input type="radio" name="sShape" value="Octagon" checked>Octagon<br>
<!--Set variable sShape equal to user's option.-->
<fieldset>
<legend>Spindle dimensions:</legend>
Height:<br>
<input type="text" name="tHeight"><br>
<!-- Text should only be positive integers greater than zero. Set variable tHeight equal to user's input. Must comply with ratios.-->
Width:<br>
<input type="text" name="tWidth"><br>
<!-- Same constraints as height apply. Set variable tWidth equal to user's input.-->
Depth:<br>
<input type="text" name="tDepth"><br>
<!-- Same constraints as height and width. Set variable tDepth equal to user's input.-->
Slant:<br>
<input type="text" name="tSlant"><br>
<!-- Text can be both positive and negative integers, as well as zero. Cannot exceed -80 or 80 degrees. Set variable tSlant equal to user's input.-->
</fieldset>
<input type="submit" name="Submit" value="Submit">
</form>
我有什麼至今在PHP代碼:
<?php var_dump($_POST) ?><br>
Pillar base shape: <?php echo $_POST["tBase"]; ?><br>
Pillar dimensions: <?php echo htmlspecialchars($_POST["tHeight"])." x ".htmlspecialchars($_POST["tWidth"])." x ".htmlspecialchars($_POST["tDepth"]); ?><br>
到目前爲止,當這些結果進行組合,我可以看到的var_dump陣列中的字符數形狀(即[「tBase」] =>字符串(7)「八角形」),但是對於數字值來說,沒有字符計數,這意味着數值沒有通過。任何人都可以幫我解決這個問題嗎?謝謝。
良好的通話。我檢查了我的代碼,結果證明我有重複。 ...但即使是變化的變化,它仍然顯示爲0 x 0 x 0. –
好的,我不需要你爲我完成整個代碼,但是我從代碼中獲取了所需的代碼。謝謝。我可以自己完成所有其他事情,例如使用我所做的一切。 –