我想制作一个贷款计算器,首先检查用户的资格,然后继续计算每月分期付款。我正在使用PHP和HTML来达到这个目的。我想知道当用户单击HTML按钮时,一个php代码或函数在单击该按钮时运行。以下是我的代码,请告诉我该怎么做。如何使用PHP和HTML制作贷款计算器?
<?php
function checkEligibility(){
if(isset($_post['country'])=="Pakistan"){
echo "You are Eligibile for this loan";
}else{
echo "Your are Not Eligibile For This Loan";
}
return false;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>
Car Loan in PHP
</title>
</head>
<body>
<form name="check" method="post">
<table border="1px" align="center" width="700" cellpadding="10"
cellspacing="0">
<tr>
<td colspan="2" >
<div align="center" style="font-size:30px; background-
color:red">This is Car Loan in PHP</div>
</td>
</tr>
<tr>
<td>
Please Select Your Country :
</td>
<td>
<select name="country" required>
<option value="">-- Select Your Country--</option>
<option value="Pakistan">Pakistan</option>
<option value="Usa">Usa</option>
<option value="Uk">Uk</option>
</select>
</td>
</tr>
<tr>
<td>
Select Your Occupation :
</td>
<td>
<select name="occupation" required>
<option value="">-- Select Your Occupation</option>
<option value="Salaried">Salaried</option>
<option value="Business">Business</option>
</select>
</td>
</tr>
<tr>
<td>
Select Your Age :
</td>
<td>
<input type="number" name="textAge" min="21" max="80"
placeholder="21" required>
</td>
</tr>
<tr>
<td>
Enter Your Monthly Income :
</td>
<td>
<input type="number" name="textIncome" min="10000"
max="8000000000" placeholder="10000" step="10000"
required>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<button style="background-color:green; color:white;
font-size:20px; border:4px solid red"
onclick="return checkEligibility()" type="button"
name="checkEl" value="btn1">Check Eligibility</button>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
你有什么已经试图做到这一点?您没有包含任何试图执行您所询问的功能的代码。请回顾[我如何问一个好问题](https://stackoverflow.com/help/how-to-ask)。堆栈溢出不是一种编码服务。预计您会在发布之前研究您的问题,并尝试亲自编写代码***。如果您遇到的东西*规范*,回来和包括[最小,完整,可验证的示例](https://stackoverflow.com/help/mcve)和你尝试过什么样的总结,所以我们可以提供帮助。 – FluffyKitten
我想知道我们如何检查从
来实现这一点您不能从窗体单击运行PHP代码。 PHP存在于服务器上,并且在浏览器中调用它,就像它是javascript – RiggsFolly