dongliu5475 2017-04-11 10:32
浏览 75
已采纳

表单和PHP在一个文件中

I am just tottaly newbie with PHP and I am now learning how to combine PHP with HTML form. I wanted it in one file, so I tried this:

<?php    
if(isset($_POST['button'])){ //check if form was submitted
  $pohlavie = $_POST['gender']; //get input text
  $plat = $_POST['salary']; //get input text
  $plat = "Your gender is ".$pohlavie." and your salary is ".$plat;
}    
?>

<center><h1>TAXES</h1></center>
<form action="" method="post">
Name: <input type="text" name="name"><br>
  <input type="radio" name="gender" value="female"> Female<br>
  <input type="radio" name="gender" value="male"> Male<br>
Salary: <input type="number" name="salary"><br>
<button type="submit" name="button" formmethod="post">Calculate DPH</button>
</form>

Unfortunately, it's literally doing nothing after submitting. Can you please help me a little bit?

  • 写回答

4条回答 默认 最新

  • douzheng9221 2017-04-11 10:38
    关注

    Trying the using the following line in place of your current form line:

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">`
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?