在表单提交时调用特定的PHP函数

编程入门 行业动态 更新时间:2024-10-25 23:24:12
本文介绍了在表单提交时调用特定的PHP函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在提交表单时调用特定的php函数,该表单和php脚本都在同一页面中.我的代码在下面.(它不起作用,所以我需要帮助)

I was trying to call a particular php function in submit of a form both the form and php scripts are in same page. My code is below.(it is not working and so I need help)

<html> <body> <form method="post" action="display()"> <input type="text" name="studentname"> <input type="submit" value="click"> </form> <?php function display() { echo "hello".$_POST["studentname"]; } ?> </body> </html>

推荐答案

在以下行中

<form method="post" action="display()">

动作应该是脚本的名称,并且应该调用函数

the action should be the name of your script and you should call the function, Something like this

<form method="post" action="yourFileName.php"> <input type="text" name="studentname"> <input type="submit" value="click" name="submit"> <!-- assign a name for the button --> </form> <?php function display() { echo "hello ".$_POST["studentname"]; } if(isset($_POST['submit'])) { display(); } ?>

更多推荐

在表单提交时调用特定的PHP函数

本文发布于:2023-11-27 19:37:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639338.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时调   表单   函数   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!