douxing1969 2015-10-14 03:39
浏览 55
已采纳

简单的计算器无法正常工作

I want to develop an ez breezy calculator to upload to a page on my site. I have written both the HTML and PHP code to the best of my understanding but still fail to produce an answer to my screen. After I click the "button", I get redirected to a blank screen with no code. When I try it in my site, it takes me back to my home page...every time! Below is all the code...I need help!

<?php
    $a=$_POST["'a'"];
    $b=$_POST["'b'"];
    $c=0;    
?> 
<meta charset="utf-8">
<html>

<head>
<title>Proposal Sheet Calculator</title>
</head>
<body>
<form method="post" action="/Merchant Calc 1.php">
<h1>How Much Money Are You Losing?</h1>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>How many clients walk out your business each month when finding out they don't have the cash or credit to pay?<br/>
    <input type="text" name="'a'"><br/></h2>
<h2>What is your average ticket price?<br/>
    <input type="text" name="'b'"><br/></h2>
<p>&nbsp;</p>
<h2><input name="calc" type="Submit" value="Show me the numbers" /></h2>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br/>
<p>
<?php
$a = $_POST[‘a’];
$b = $_POST[‘b’];
$c=$a*$b
// should output $a*$b
if(isset($_POST[‘submit’])){
echo "$a * $b";
}

more?<br/>
<input type="text" name="'Y/N'"><br/>
<input name="calc" type="Submit" />
if(isset($_POST[‘submit’]))<br/>
</p>
?>
</form>
</body>
</html>

I don't even get to the "more?" input...it dumps me out before that so I have not done anything below the "more?" lines. And the crazy output of the last if statement...WebMatrix shows no errors.?.?.?.? Thanks in advance!

  • 写回答

2条回答 默认 最新

  • douhe8981 2015-10-14 07:30
    关注
    <?php
    error_reporting(0);
    ?>
    <html>
    
    <head>
    <title>Proposal Sheet Calculator</title>
    </head>
    <body>
    <form method="post" action="">
    <h1>How Much MONEY Are You Losing?</h1>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <h2>How many clients walk out your BUSINESS each month when finding out they don't have the cash or credit to pay?<br/>
        <input type="text" name="a"><br/></h2>
    <h2>What is your average ticket price?<br/>
        <input type="text" name="b"><br/></h2>
    <p>&nbsp;</p>
    <h2><input name="calc" type="Submit" value="Show me the numbers" /></h2>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <br/>
    <p>
    <?php
    $a = $_POST["a"];
    $b = $_POST["b"];
    $c=$a*$b;
    // should output $a*$b
    if(isset($_POST["calc"])){
    echo $c;
    }
    
    ?><br/>
    <input type="text" name="'Y/N'"><br/>
    <input name="calc" type="Submit" />
    <br/>
    </p>
    </form>
    </body>
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备