单击表单中的提交按钮后,无法访问Imagecord功能

时间:2014-03-21 19:29:53

标签: php

</head>
<BODY>

<?php
        function Aftersubmit()
    {
        $myname = $_POST['myname'];
        if(isset($myname)){
        echo ($myname);

        }

    }
        function Imagecord()
    {
        if(isset($xcoord) && isset($ycoord)){
        $xcoord=$_POST["myimage_x"];
        $ycoord=$_POST["myimage_y"];
        echo ("X=".$xcoord);
        echo ("Y=".$ycoord);
        }
    }


    if(isset($_POST['submitbutton'])){
        Aftersubmit();
        Imagecord();
    }

?>

无法访问Imagecord()函数,例如PHP中的Aftersubmit按钮。 我想点击图片,提交后应该显示坐标。

2 个答案:

答案 0 :(得分:0)

修改功能

function Imagecord()
    {
        if(isset($_POST["myimage_x"]) && isset($_POST["myimage_y"])){
        $xcoord=$_POST["myimage_x"];
        $ycoord=$_POST["myimage_y"];
        echo ("X=".$xcoord);
        echo ("Y=".$ycoord);
        }
    }

答案 1 :(得分:0)

<html>
<head>


</head>
<BODY>

<?php
        function Aftersubmit()
    {
        $myname = $_POST['myname'];
        if(isset($myname)){
        echo ($myname);

        }

    }
        function Imagecord()
    {

        $xcoord=$_POST['myimage_x'];
        $ycoord=$_POST['myimage_y'];
        echo "X=".$xcoord;
        echo "Y=".$ycoord;


    }


    if(isset($_POST['submitbutton'])){
        Aftersubmit();
        Imagecord();
    }

?>

<script>
        function myJavascriptFunction(){
            alert ("hello World");
        }

</script>

    <form   action= "forms.php" enctype = "multipart/form-data" method="post">
        first name: <input type="text" name="firstname" value="Mary"><br>
        Last name: <input type="text" name="lastname" value= "clan"><br>
        <input type="checkbox" name="mychoices[]" value="choice1" checked>
        <input type="checkbox" name="mychoices[]" value="choice2">
        <input type="checkbox" name="mychoices[]" value="choice3">
        <select name="myselection">
        <option value="selection1" selected>Option1</option>
        <option value="selection2">Option2</option>
        <option value="selection3">Option3</option>
        </select>
        <select name="myselections[]" size="3" multiple>
        <option value="choice1" selected >Choice1</option>
        <option value="choice2" selected>choice2</option>
        <option value="choice3">choice3</option>
        </select>
        <textarea name="mytextarea" rows="10" cols="40">
        Welcome to the web developement world.
        </textarea>
        <input type="password" name="mypassword"/>
        <input type="hidden" name="myname" value = "myvalue"/>
        <input type="file" name="text"  size="100"/>
        <input type="button" value="My Button" onclick="myJavascriptFunction()"/>
        <input type="reset" value="reset form"/>
        <input type="image" name="myimage" src="desert.jpg" height="42" width="42">
        <input type="submit" name="submitbutton" value="Submit Form"/>

    </form>


</BODY>
</HTML>