小编Gna*_*dra的帖子

如何在按钮点击时调用php函数

这是两个文件

Calling.php

<html>
<body>
<form action="Called.php" method="get">
    <input type="button" name="B1" value="B1">
    <input type="button" name="B2" value="B2">
    <input type="Submit" name="Submit1"/>

    <!-- <a href="http://www.google.com?act=google">Google</a>
    <a href="http://www.yahoo.com?act=yahoo">yahoo</a>
     -->
</form>     
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

和Called.php

<?php
if(isset($_GET("Submit1")))
{   
        echo("<script>location.href = 'http://stackoverflow.com';</script>");
}
if(isset($_GET["B1"]))
{
    echo("<script>location.href = 'http://google.com/';</script>");
    exit();
} 
if(isset($_GET["B2"]))

 - List item

{
    echo "<meta http-equiv='refresh' content='0;url=http://www.yahoo.com'>";
    exit(); 
}
?>
Run Code Online (Sandbox Code Playgroud)

当我点击按钮"B1"和"B2"时,页面将闪烁,但现在重定向和第三个"提交"按钮将重定向到新页面,我在那里得到输出为"Called.php".

请花几秒钟为这个php初学者.

php

5
推荐指数
1
解决办法
8万
查看次数

标签 统计

php ×1