QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3883|回复: 7

如何实现一个按钮调用php里面的一个函数

[复制链接]
发表于 2005-8-10 03:26:37 | 显示全部楼层 |阅读模式
这两段都在一个php里:study2.php

<form method = "post" action ="study2.php">
<input name="botton1" type="button"  value="testphp" >
</form>



<?php

if ($check1)
{testphp();}

意思是点击testphp按钮就可以测试php的状态

怎么让他们俩勾搭在一起?
发表于 2005-8-10 09:14:01 | 显示全部楼层
如果点击了botton1按钮...
[code:1]

if ( isset($_POST['botton1']) ) {
    do your stuff here such as test php's state...
}

[/code:1]
回复

使用道具 举报

 楼主| 发表于 2005-8-10 16:06:24 | 显示全部楼层
不好意思,打错了
<?php
function testphp()
{
phpinfo();
}
?>
回复

使用道具 举报

发表于 2005-8-10 16:14:35 | 显示全部楼层
[code:1]
if ( isset($_POST['botton1']) ) {
    // do your stuff here such as test php's state...
    phpinfo();
    ...
}
[/code:1]
回复

使用道具 举报

 楼主| 发表于 2005-8-10 16:17:44 | 显示全部楼层
<input name="botton1" type="button" value="testphp" >
这个就这么写?那他能知道送给的是 testphp这个函数?
回复

使用道具 举报

发表于 2005-8-10 16:26:30 | 显示全部楼层
[code:1]表现层
<form action="./test.php" method="post" name="test">
<input name="botton1" type="submit" value="测试PHP" >
</form>
[/code:1]

[code:1]业务逻辑层
/**
* if ccat click "测试PHP", then...
*/
if ( isset($_POST['botton1']) ) {
    // do your stuff here such as test php's state...
    phpinfo();
    ...
}
[/code:1]
回复

使用道具 举报

发表于 2005-8-10 18:21:20 | 显示全部楼层
if ( isset($_POST['botton1']) ) {

if ( $_POST['botton1'] == "测试PHP" ) {

:neutral:
这样能明白了吧?
回复

使用道具 举报

 楼主| 发表于 2005-8-10 18:53:07 | 显示全部楼层

明白了,可以了,谢谢各位。
我已经感受到linux的热情了。
我会把热情继续的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-26 11:53 , Processed in 0.151579 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表