本文介绍了在表单提交时调用特定的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函数
发布评论