从同一页面上的php函数调用表单提交动作 [英] Call form submit action from php function on same page

查看:133
本文介绍了从同一页面上的php函数调用表单提交动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个简单的Web应用程序。为了减少文件的数量,我想把表单提交功能的(php)代码放到同一页面中。像这样:

 < body> 
< form id =rsvp-status-formaction =rsvpsubmitmethod =post>
< input type =radioname =rsvp-radiovalue =yes/>是<峰; br />
< input type =radioname =ravp-radiovalue =nochecked />否LT峰; br />
< input type =radioname =rsvp-radiovalue =notsure/>不确定< br />
< input type =submitvalue =submit/>
< / form>
< / body>

$ php
函数rsvpsubmit(){
//在这里做的东西
}

调用submit函数的正确方法是什么?

解决方案

当你修好你的收音机组,以便它们都具有相同的名称:

  if(isset($ _ POST ['rsvp-radio' ])){
rsvpsubmit();
}


I'm working on a simple web application. In order to reduce the number of files, I want to put (php) code for a form submit function into the same page as the form. Something like this:

<body>
   <form id = "rsvp-status-form" action = "rsvpsubmit" method = "post">
     <input type="radio" name="rsvp-radio" value="yes"/> Yes<br/>
     <input type="radio" name="ravp-radio" value="no" checked/> No<br/>
     <input type="radio" name="rsvp-radio" value="notsure"/> Not Sure<br/>
     <input type="submit" value="submit"/>
   </form>
 </body>

<?php 
  function rsvpsubmit() {
    // do stuff here
  }

What is the proper way to call the submit function?

解决方案

After you fix your radio group so they all have the same name:

if (isset($_POST['rsvp-radio'])) {
    rsvpsubmit();
}

这篇关于从同一页面上的php函数调用表单提交动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆