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条)

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)