-1

I have a problem here...I have a file map.php with this content:

<html>
<head>
</head>                         
<body>
    <div class="wrapper">
        <!--harta-->
        <form id="harta" action='' method=post style="overflow:scroll; height: 598px; width: 848px;">
            <input type="image" src="../../design/images/maps/romania.jpg" 
name="foo" style=cursor:crosshair;/>
        </form>
        <!--bara de coordonate-->
        <div class="coordxy" style="hight:30px; width:80px; position:relative; top:-20; left:50px; border:3px solid #42aaf4">
            <?Php
            $foo_x=$_POST['foo_x']/20;
            $foo_y=$_POST['foo_y']/20;
            $x=(ceil($foo_x));
            $y=(ceil($foo_y));
            echo "X=".$x; echo "Y=".$y;
            ?>
        </div>
        <!--linkul img-->
        <iframe id="detaliisate" src="../../account-handeling/mapxy-handler.php" frameborder="0" border="0" cellspacing="0"
style="overflow:scroll; border-style: none; position:relative; width: 150px; height: 120px; margin-right:15px;left:678px; top: -640px;">iframul</iframe>
    </div>
</body>
</html>

I managed to get the coordinates by mouse pointing on a map, like simulating a tiled map, so I write the function to get mouse x-y coordinates on a image then divide results by the tile dimension, then ceil() the results at higher value...voilla...

All works fine, I have the coordinates displayed in <div class="coordxy" when I click, but the page is refreshing every time, but I don't think that is the problem.

When I want to get them in a iframe'mapxy-handler.php, it wont work:

<?php
include '../pages/countrymap/map.php';
global $x;
global $y;
?>
<div class="ffff"><?php echo $x;?></div>

It gives me some random elements as text from map.php like Submit and 2 errors:

( ! ) Notice: Undefined index: foo_x in C:\wamp\www\WorldDomination\pages\countrymap\map.php on line 27 Call Stack # Time Memory Function Location 1 0.0005 357448 {main}( ) ...\mapxy-handler.php:0 2 0.0007 361304 include( 'C:\wamp\www\WorldDomination\pages\countrymap\map.php' ) ...\mapxy-handler.php:7

( ! ) Notice: Undefined index: foo_y in C:\wamp\www\WorldDomination\pages\countrymap\map.php on line 28 Call Stack # Time Memory Function Location 1 0.0005 357448 {main}( ) ...\mapxy-handler.php:0 2 0.0007 361304 include( 'C:\wamp\www\WorldDomination\pages\countrymap\map.php' ) ...\mapxy-handler.php:7

What may be going wrong?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
Botea Florin
  • 543
  • 6
  • 24

1 Answers1

1

This has nothing to do with globals. You're accessing a part of an array ($_POST) that does not exist.

This: $_POST['foo_x'] throws the error as you can read because the key 'foo_x' does not exist.

The error does help a bit here:

Notice: Undefined index: foo_x in C:\wamp\www\WorldDomination\pages\countrymap\map.php on line 27

Breaking it down:

  • there is a notice
  • you have an undefined index
  • it is called "foo_x"
  • the file you are looking for is "map.php"
  • the line-number is 27
Nanne
  • 64,065
  • 16
  • 119
  • 163