如何解决服务器上找不到的URL问题?
我正在尝试使用HTML和PHP创建一个简单的货币转换器。我已经在计算机上下载了MAMP软件包(本地主机)。但是,当单击“转换”按钮时,我会发现一个错误:“该服务器上找不到所请求的URL。”谁能帮我找出问题是什么?
这是代码:
<html>
<head>
<style>
#box
{
width:350px;
height:270px;
margin:0px auto;
border:2px solid black;
}
h2{
text-align: center;
}
table{
margin:0px auto;
}
</style>
</head>
<body>
<form align="center" action="currencyconvertor.php" method="post">
<div id="box">
<h2><center>Currency Converter</center></h2>
<table>
<tr>
<td>
Enter Amount:<input type="text" name="amount"><br>
</td>
</tr>
<tr>
<td>
<br><center>From:<select name='cur1'>
<option value="AUD">Australian Dollar(AUD)</option>
<option value="USD" selected>US Dollar(USD)</option>
</select>
</td>
</tr>
<tr>
<td>
<br><center>To:<select name='cur2'>
<option value="INR" selected >Indian Rupee(INR)</option>
<option value="JPY">Japanese Yen(JPY)</option>
<option value="PHP">Philippine Peso(PHP)</option>
</select>
</td>
</tr>
<tr>
<td><center><br>
<input type='submit' name='submit' value="CovertNow"></center>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])){
$amount = $_POST['amount'];
$cur1 = $_POST['cur1'];
$cur2 = $_POST['cur2'];
if($cur1=="AUD" AND $cur2=="JPY"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount*82.463 . "</center>";
}
if($cur1=="AUD" AND $cur2=="INR"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 51.09 . "</center>";
}
if($cur1=="AUD" AND $cur2=="PHP"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 37.15 . "</center>";
}
if($cur1=="USD" AND $cur2=="JPY"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 109.49 . "</center>";
}
if($cur1=="USD" AND $cur2=="INR"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 67.83 . "</center>";
}
if($cur1=="USD" AND $cur2=="PHP"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount*49.32 . "</center>";
}
}
?>
</body>
</html>
感谢您的帮助
I am trying to create a simple currency converter with html and php. I have downloaded the MAMP package (local host) on my computer. But when click on the convert button, I get an error : "The requested URL was not found on this server." Can anyone help me find out what is the problem?
Here is the code:
<html>
<head>
<style>
#box
{
width:350px;
height:270px;
margin:0px auto;
border:2px solid black;
}
h2{
text-align: center;
}
table{
margin:0px auto;
}
</style>
</head>
<body>
<form align="center" action="currencyconvertor.php" method="post">
<div id="box">
<h2><center>Currency Converter</center></h2>
<table>
<tr>
<td>
Enter Amount:<input type="text" name="amount"><br>
</td>
</tr>
<tr>
<td>
<br><center>From:<select name='cur1'>
<option value="AUD">Australian Dollar(AUD)</option>
<option value="USD" selected>US Dollar(USD)</option>
</select>
</td>
</tr>
<tr>
<td>
<br><center>To:<select name='cur2'>
<option value="INR" selected >Indian Rupee(INR)</option>
<option value="JPY">Japanese Yen(JPY)</option>
<option value="PHP">Philippine Peso(PHP)</option>
</select>
</td>
</tr>
<tr>
<td><center><br>
<input type='submit' name='submit' value="CovertNow"></center>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])){
$amount = $_POST['amount'];
$cur1 = $_POST['cur1'];
$cur2 = $_POST['cur2'];
if($cur1=="AUD" AND $cur2=="JPY"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount*82.463 . "</center>";
}
if($cur1=="AUD" AND $cur2=="INR"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 51.09 . "</center>";
}
if($cur1=="AUD" AND $cur2=="PHP"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 37.15 . "</center>";
}
if($cur1=="USD" AND $cur2=="JPY"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 109.49 . "</center>";
}
if($cur1=="USD" AND $cur2=="INR"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 67.83 . "</center>";
}
if($cur1=="USD" AND $cur2=="PHP"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount*49.32 . "</center>";
}
}
?>
</body>
</html>
Thanks for help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是 filenotfoundException : crurnerconverter.php 不存在(也许是错字错误?),或者不在与 index.php 。
我用 action =“#” 对您的表格进行了测试,以重定向到同一页面,并且它可以很好地工作,因此您的问题除了表格的操作之外没有任何东西...
此处如果您能够生成第一页并查看表格,则问题不能来自MAMP;)
It is a FileNotFoundException : currencyconverter.php doesn't exist (maybe a typo error ?) or is not in the same directory as index.php.
I tested your form with action="#" to redirect to the same page and it works perfectly, so your problem cannot be anything but the form's action...
The problem cannot come from MAMP if you are able to generate the first page and to see the form ;)