帮助从表单和数学计算中检索信息时遇到问题 [英] Help have a problem with retrieving info from forms and math calculation
问题描述
嗨我不确定我在下面的脚本中犯了什么错误任何人都可以请你帮忙
batttle.php
< span class =code-keyword>< html >
< body >
<? php
$ a = $ _GET [ attack];
$ d = $ _GET [ 防御跨度>];
$ attacker =(($ d / $ a)^ 1.5]));
$ defender =(($ a / $ d)^ 1.5]);
?>
< br >
简单战斗计算器 < br > < br >
攻击HP : <? php echo $ _GET [ attack]; ?> < br >
攻击HP: <? php echo $ _GET [ defense]; ?> < br > < br > < br >
> <? php if ( $ defender > = 100 ){echo 攻击者获胜。;} else { echo 后卫获胜。;} ?> < br >
< p > 攻击船舶丢失:< span < span class =code-attribute> style = color:red > <? php if ($ attacker> = 100 ){echo 100;} else {
echo $ attacker ;} ?> < / span > %< < /温泉n> br >
< br > < br >
后卫船舶损失:< span style = color:red > <? php if ( $ defender > = 100 ){echo 100 ;} else { echo $ defender ;} ?> < / span > %< br >
包括menu2.php;
?>
< / body >
< / html >
Hi I'm not sure where I made a mistake in the following script can anyone please assist 这篇关于帮助从表单和数学计算中检索信息时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
index.php(表格)
< pre lang =PHP> < pre lang = xml < span class =code-keyword>> < !DOCTYPE HTML >
< html >
< head >
< style >
。 error { color : #FF0000; }
< / style >
< / head >
< body > < span class =code-keyword>< form method = get action = 战斗。 php >
攻击HP:< input type = text 名称 = 攻击 value = <?php echo $ attack;?> > < br > < br
防御HP:< input type = text name = 防御 value = <?php echo $ defense;?> > < br > < br >
< input 类型 = 提交 名称 = 提交 value = 提交 >
< / form > < br > < br > < p > < / a >
< ; / body >
< / html > a =
_GET [ 攻击跨度>];
d =
batttle.php
<html>
<body>
<?php
$a = $_GET["attack"];
$d = $_GET["defence"];
$attacker = (($d / $a)^1.5]));
$defender = (($a / $d)^1.5]);
?>
<br>
Simple Battle Calculator<br><br>
Attack HP: <?php echo $_GET["attack"]; ?><br>
Attack HP:<?php echo $_GET["defence"]; ?><br><br><br>
"><?php if ( $defender >= 100 ) {echo "Attacker wins.";} else { echo "Defender wins.";} ?><br>
<p>Attacker ship loss: <span style="color:red"><?php if ($attacker >= 100 ) {echo "100";} else {
echo $attacker;} ?></span>%<br>
<br><br>
Defender ship loss: <span style="color:red"><?php if ( $defender >= 100 ) {echo "100";} else { echo $defender;} ?></span>% <br>
include "menu2.php";
?>
</body>
</html>
index.php (form)
<pre lang="xml"><!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body> <form method="get" action="battle.php">
Attack HP:<input type="text" name="attack" value="<?php echo $attack;?>"><br><br>
Defence HP:<input type="text" name="defence" value="<?php echo $defence;?>"><br><br>
<input type="submit" name="submit" value="Submit">
</form><br><br><p></a>
</body>
</html>
a =
_GET["attack"];
d =