Php 代码问题无法工作,不确定我的语法是否已关闭或缺少任何内容
由于我是PhP新手,所以遇到了5个我似乎无法理解的错误,这非常令人困惑,这是家庭作业,但我做了一个很好的分享,我只需要找出问题所在,然后用代码注释代码问题 对问题进行了评论 我试着修改语法,结果弄坏了东西,所以我又回到了原来的版本Php 代码问题无法工作,不确定我的语法是否已关闭或缺少任何内容,php,Php,由于我是PhP新手,所以遇到了5个我似乎无法理解的错误,这非常令人困惑,这是家庭作业,但我做了一个很好的分享,我只需要找出问题所在,然后用代码注释代码问题 对问题进行了评论 我试着修改语法,结果弄坏了东西,所以我又回到了原来的版本 <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template fil
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title> Shippee Credit Interest </title>
</head>
<body>
<h2> Credit Interest Monthly Payments </h2>
<form action="Shippeelab1.php" method="post">
<!-- Input -->
Credit:
<input type="text" value="2157" name="credit">
Interest Rating:
<input type="text" value="26.22" name="interest">
Monthly Payments:
<input type="text" value="65" name="monthly">
<!-- Button -->
<input type="submit" value="Calculate!" name="btnCalc">
</form>
<?php
if (isset ($_POST['btnCalc'])) // 1.Do not Access Superglobal $_POST Array Directly
{
$owe = $_POST['credit']; // 2. Do not Access Superglobal $_POST Array Directly
$interest = $_POST['interest']; //Do not Access Superglobal $_POST Array Directly
$payment = $_POST['monthly']; //Do not Access Superglobal $_POST Array Directly
echo "<table align='left' border='3>";
echo "<th> Months </th>";
echo "<th> Interest </th>";
echo "<th> Still Owed </th>";
//Stored Balance
$CC = $owe;
for ($array = 0; $owe > 0; $i++)
{
//Calulation for Interest
$paid = $owe * $interest / 100 / 12;
//Interest Payments
$bill = $owe + $interestPay;
//Balance Remainder
$remainder = $owe - $payment + $interestPay;
if($paid > $remainder)
{
$remainder = "";
}
echo "<tr>"
$rowMonth = $array + 1; //3. Syntax error variable'$rowMonth'
$rowInterest = '$' .number_format((float)$paid, 2);
$rowRemainder '$'.number_format((float)$remainder, 2);//4. possible syntax error string '$'
echo "<td> $rowMonth </td>";
echo "<td> $rowInterest </td>";
echo "<td> $rowRemainder </td>";
echo "</tr>";
$owe = $balance;
}
echo "</table>";
$total = $CC + $bill;
echo "<br>", "You paid over " .rowMonth, " months equals out to $".number_format((float)$total, 2);
}
else
{
echo "";
}
?>
</body>
</html>
船货信用利息
信用利息按月支付
学分:
利率评级:
每月付款:
它不是编译,这就是我真正需要它做的,我仍然认为我的语法和问题是错误的。感谢您的帮助
编辑
我的if语句将运行,但我得到的错误最终是
1和2应该是$\u Post[“”](双引号)。3.你错过了一次机会;在你的回声之后。4$ROWRESTRION未被设置为等于任何值。
//3。
是缺少的代码>来自上一行。感谢我修复了一系列问题,我尝试了过滤器输入,它工作得有点好,但现在我仍然会收到错误,如果大的正在运行页面,我尝试更改我的if statment for if(isset)的Superglobal但它打破了页面,在编辑@FOX91中添加了一张图片供您查看为什么您需要对1和2使用双引号?双引号中的项目将被评估,而单引号中的项目将不会。正确-但这将如何影响像$\u POST['credit']
?这些解决了很多问题,但我的if(isset)仍然有问题