Page 1 of 1

Map Location Issue

Posted: Sat Aug 24, 2013 5:56 am
by Epiales
I noticed in your video where you put locations from your index instead of using another page. I decided to do another page, based upon my setup. When I switch it to an internet server, that may change, but in the meantime I want to use map.php, which I have the code below.

Code: Select all

<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
 $id=$_SESSION['id'];
    echo "You must be logged in to view this page!";
}else{
?>


<?php
if(!isset($_GET['map'])){

$id = $user['id'];
$bypass=1;
echo "<a href='map.php?mapchange=1&mapname=Las Vegas'>Las Vegas</a><br /><br />";
echo "<a href='map.php?mapchange=1&mapname=Reno Nevada'>Reno Nevada</a><br /><br />";
echo "<a href='map.php?mapchange=1&mapname=St Louis Missouri'>St Louis Missouri</a><br /><br />";
}

if(!isset($_GET['mapchange'])){

$bypass=1;
$mapname = $_GET['mapname'];

$updateplayer="update stats set location='$mapname' WHERE id='$id'";
  mysql_query($updateplayer) or die("Could not update player");
  
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='map.php'>To location</a><br>";

    }
    }
?>
Now I didn't see any difference in my code and yours, so I'm lost on why I get the error.... This is what it shows:

Las Vegas

Reno Nevada

St Louis Missouri


Notice: Undefined index: mapname in C:\xampp\htdocs\game\map.php on line 25
You have traveled to .
To location

Re: Map Location Issue

Posted: Sat Aug 24, 2013 6:44 am
by Epiales
Okay, I have to remove the:

{
$bypass=1;

From the top and it now shows the first two locations but not the current one. And it shows that you have traveled there and updates in db....

current code:

Code: Select all

<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){

    echo "You must be logged in to view this page!";
}else{
$id = $user['id'];
if(isset($_GET['map']))


echo "<a href='map.php?mapchange=1&mapname=Crocania'>Crocania</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Fordale Woods'>Fordale Woods</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Mintus Mountains'>Mintus Mountains</a><br>";
}

if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];

$updateplayer="update stats set location='$mapname' where id='$id'";
  mysql_query($updateplayer) or die("Could not update player");
  
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='map.php'>To location</a><br>";
}

?>
not sure why it doesn't show the current location, and not sure why I had to remove the bypass?

Re: Map Location Issue

Posted: Sat Aug 24, 2013 7:05 am
by Epiales
Okay.. LOL..Not sure why it's not working, but doing it this way works:

Code: Select all

echo "<a href='map.php?mapchange=1&mapname=Las Vegas'>Las Vegas</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Reno Nevada'>Reno Nevada</a><br>";
echo "<a href='map.php?mapchange=1&mapname=St Louis Missouri'>St Louis Missouri</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Las Vegas'>Las Vegas</a><br>"; 
and I have to leave that first Las Vegas in there or the Reno doesn't show LOL. Oh well, it works YAY

Re: Map Location Issue

Posted: Sun Aug 25, 2013 10:35 am
by MikuzA
Hello,

You might want to simplify the links, instead of mapname use id.
Unable to analyse the issue more closely at this time, nyt sure looks a bit weird.