Only attack the selected “item” if I click on the attack button?

If I click on the map the PHP shows some information regarding what I can attack.

But I want to attack it only if I click to the attack button, and if I click on the map the program chooses another wild_id.

My problem is, If I click on the map the code correctly chooses a wild_id, but if I click on the map I can’t fight with the wild_id why?

Where you see +++ is the relevant portion of code I have mentioned.

Here is my code:

[php]<?
//Script laden zodat je nooit pagina buiten de index om kan laden
include(“includes/security.php”);

//Kijken of je wel pokemon bij je hebt
if($gebruiker['in_hand'] == 0) header('location: index.php');

$page = 'attack/attack_map';
//Goeie taal erbij laden voor de page
include_once('language/language-pages.php');


if(mysql_num_rows(mysql_query("SELECT `id` FROM `pokemon_speler` WHERE `user_id`='".$_SESSION['id']."' AND `ei`='0' AND `opzak`='ja'")) > 0){
  if((isset($_POST['gebied'])) && (is_numeric($_POST['gebied']))){
    if($_POST['gebied'] == 1) $gebied = 'Lavagrot';
    elseif($_POST['gebied'] == 2) $gebied = 'Vechtschool';
    elseif($_POST['gebied'] == 3) $gebied = 'Gras';
    elseif($_POST['gebied'] == 4) $gebied = 'Spookhuis';
    elseif($_POST['gebied'] == 5) $gebied = 'Grot';
    elseif($_POST['gebied'] == 6) $gebied = 'Water';
    elseif($_POST['gebied'] == 7) $gebied = 'Strand';


    if($gebruiker['in_hand'] == 0)
      echo '<div class="blue"><img src="images/icons/blue.png"> '.$txt['alert_no_pokemon'].'</div>';
    elseif(($gebied == 'Water') AND ($gebruiker['Fishing rod'] == 0))
      $error    = '<div class="red">'.$txt['alert_no_fishing_rod'].'</div>';
    elseif(($gebied == 'Grot' || $_POST['gebied'] == 'Lavagrot') AND ($gebruiker['Cave suit'] == 0))
      $error    = '<div class="red">'.$txt['alert_no_cave_suit'].'</div>';
    else{
      //Zeldzaamheid bepalen
      $zeldzaam = rand(1,2500);
      if($zeldzaam <= 100) $trainer = 1;// Team Rocket
      elseif($zeldzaam <= 2100) $zeldzaamheid = 1;
      elseif($zeldzaam <= 2499) $zeldzaamheid = 2;
      elseif($zeldzaam == 2500) $zeldzaamheid = 3;

        if(($gebruiker['rank'] > 15) && (!empty($gebruiker['lvl_choose']))){
          $level = explode("-", $gebruiker['lvl_choose']);
          $leveltegenstander = rand($level[0],$level[1]);
        }
        else $leveltegenstander = rankpokemon($gebruiker['rank']);

        $query = mysql_fetch_assoc(mysql_query("SELECT wild_id FROM `pokemon_wild` WHERE `gebied`='".$gebied."' AND `wereld`='".$gebruiker['wereld']."' AND `zeldzaamheid`='".$zeldzaamheid."' ORDER BY rand() limit 1"));
        //Geen pokemon geen gekozen
        if(empty($query['wild_id']))
 $query = mysql_fetch_assoc(mysql_query("SELECT wild_id FROM `pokemon_wild` WHERE `gebied`='".$gebied."' AND `wereld`='".$gebruiker['wereld']."' AND `zeldzaamheid`='1' ORDER BY rand() limit 1"));
          //echo "<div class='red'>".$txt['alert_error']." 100".$zeldzaamheid.".</div>";
        //else{

+++ if(isset($_POST[‘submit’])){
include(“attack/wild/wild-start.php”);
$info = create_new_attack($query[‘wild_id’],$leveltegenstander,$gebied);
if(empty($info[‘bericht’])) header(“Location: ?page=attack/wild/wild-attack”);
else echo “

”.$txt[‘alert_no_pokemon’]."
";
//}
++++ }
}
}
  echo $error; ?>
        <center>
            <table width="600" border="0">
            <tr>
                <td><center><?php echo $txt['title_text']; ?></center></td>
            </tr>
            </table>
        </center>
<?php 
    if ($gebruiker['wereld'] == "Kanto") {        
    echo "<center>
    <table width='580' style='border: 1px solid #000000;' cellspacing='0' cellpadding='0'>
      <tr>
        <td><table width='580' border='0' cellspacing='0' cellpadding='0'>
          <tr>
            <td width='346' height='179'><form method='post' name='Lavagrot'><input type='image' onClick='Lavagrot.submit();' src='images/attackmap/kanto/lavagrot.gif' width='346' height='179' alt='Firecave' /><input type='hidden' value='1' name='gebied'></form></td>
            <td width='234' height='179'><form method='post' name='Vechtschool'><input type='image' onClick='Vechtschool.submit();' src='images/attackmap/kanto/vechtschool.gif' width='234' height='179' alt='Fighting gym' /><input type='hidden' value='2' name='gebied'></form></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width='580' border='0' cellspacing='0' cellpadding='0'>
          <tr>
            <td width='216' height='249'><form method='post' name='Gras'><input type='image' onClick='Gras.submit();' src='images/attackmap/kanto/grasveld.gif' width='216' height='249' alt='Grass field' /><input type='hidden' value='3' name='gebied'></form></td>
            <td width='123' height='249'><form method='post' name='Spookhuis'><input type='image' onClick='Spookhuis.submit();' src='images/attackmap/kanto/spookhuis.gif' width='123' height='249' alt='Ghosthouse' /><input type='hidden' value='4' name='gebied'></form></td>
            <td width='241' height='249'><form method='post' name='Grot'><input type='image' onClick='Grot.submit();' src='images/attackmap/kanto/grot.gif' width='241' height='249' alt='Cave' /><input type='hidden' value='5' name='gebied'></form></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width='580' border='0' cellspacing='0' cellpadding='0'>
          <tr>
            <td width='305'height='172'><form method='post' name='Water'><input type='image' onClick='Water.submit();' src='images/attackmap/kanto/water.gif' width='305' height='172' alt='Water' /><input type='hidden' value='6' name='gebied'></form></td>
            <td width='275' height='172'><form method='post' name='Strand'><input type='image' onClick='Strand.submit();' src='images/attackmap/kanto/strand.gif' width='275' height='172' alt='Beach'/><input type='hidden' value='7' name='gebied'></form></td>
          </tr>
        </table></td>
      </tr>
    </table>
    </center>";
    }
}
else{
  echo '<div style="padding-top:10px;"><div class="blue"><img src="images/icons/blue.png" width="16" height="16" /> '.$txt['alert_no_pokemon'].'</div></div>';
}

+++ echo’
+++


+++
+++
+++
+++
+++
+++
normal '.$info['naam'].'Shiny '.$query['naam'].'
# ‘.$query[‘wild_id’].’

+++ ‘.$query[‘naam’].’

+++ ‘.$query[‘type’].’
+++ ‘.$query[‘naam’].’ ‘.$txt[‘is’].’ ‘.$zeldzaam.’.

+++ ‘.$txt[‘lives_in’].’ ‘.$query[‘wereld’].’.

+++ ‘.$gebied.’

+++ ‘.$txt[‘how_much_1’].’ ‘.highamount($info[‘hoeveelingame’]).’ '.$info[‘naam’].'s ‘.$txt[‘how_much_2’].’

+++

+++
';
?>
+++

+++

+++
+++

+++

+++
+++ [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service