SO I got this (at the end of the page, and it links to the same page)
print "<a href='firstdog.php?chosendog=1&randomintellect=$randomintellect&randomkeeness=$randomkeeness&randomaggresiveness=$randomaggresiveness&weight=$weight&gender=$gender'> Buy Dog </a>"
And this at the top
if(isset($_GET['chosendog']))
I copied the structure of the link from Urban Realms, but I'm not sure how to get the variables working. I keep gettng the 'Undefined Variable randomintellect' etc etc.
Heres the whole page
firstdog.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
?>
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$pid = $playerinfo3['id'];
if(isset($_GET['chosendog']))
{
print "You chose the small but speedy greyhound!";
$updategreyhound="INSERT into greyhounds (pid,speed,intellect,size,weight,keeness,aggresiveness,gender,brokein) VALUES ('$pid','5','$randomintellect','small','$weight','$randomkeeness','$randomaggresiveness','$gender','1')";
mysql_query($updategreyhound) or die("Could not update map");
}
if(isset($_GET['chosendog2']))
{
$updatemap="Update map set crname='$crinfo3[name]',crhp='$crinfo3[hp]' where mapr='$playerinfo3[mapr]' AND mapc='$playerinfo3[mapc]'";
mysql_query($updatemap) or die("Could not update map");
}
if(isset($_GET['chosendog3']))
{
$updatemap="Update map set crname='$crinfo3[name]',crhp='$crinfo3[hp]' where mapr='$playerinfo3[mapr]' AND mapc='$playerinfo3[mapc]'";
mysql_query($updatemap) or die("Could not update map");
}
if(isset($_GET['chosendog4']))
{
$updatemap="Update map set crname='$crinfo3[name]',crhp='$crinfo3[hp]' where mapr='$playerinfo3[mapr]' AND mapc='$playerinfo3[mapc]'";
mysql_query($updatemap) or die("Could not update map");
}
///////////// Dog 1 //////////////////
$randomweight = rand(1,4);
if ($randomweight == 1) {$weight = 22;}
if ($randomweight == 2) {$weight = 23;}
if ($randomweight == 3) {$weight = 24;}
if ($randomweight == 4) {$weight = 25;}
$randomgender = rand(1,2);
if ($randomgender == 1)
{
$gender = "Male";
}
else
{
$gender = "Female";
}
$randomintellect = rand(1,100);
$randomkeeness = rand(1,100);
$randomaggresiveness = rand(1,100);
///////////// Dog 2 //////////////////
$randomweight2 = rand(1,4);
if ($randomweight2 == 1) {$weight2 = 26;}
if ($randomweight2 == 2) {$weight2 = 27;}
if ($randomweight2 == 3) {$weight2 = 28;}
if ($randomweight2 == 4) {$weight2 = 29;}
$randomgender2 = rand(1,2);
if ($randomgender2 == 1)
{
$gender2 = "Male";
}
else
{
$gender2 = "Female";
}
$randomintellect2 = rand(1,100);
$randomkeeness2 = rand(1,100);
$randomaggresiveness2 = rand(1,100);
///////////// Dog 3 /////////////////
$randomweight3 = rand(1,4);
if ($randomweight3 == 1) {$weight3 = 30;}
if ($randomweight3 == 2) {$weight3 = 31;}
if ($randomweight3 == 3) {$weight3 = 32;}
if ($randomweight3 == 4) {$weight3 = 33;}
$randomgender3 = rand(1,2);
if ($randomgender3 == 1)
{
$gender3 = "Male";
}
else
{
$gender3 = "Female";
}
$randomintellect3 = rand(1,100);
$randomkeeness3 = rand(1,100);
$randomaggresiveness3 = rand(1,100);
////////////// Dog 4 ////////////////
$randomweight4 = rand(1,4);
if ($randomweight4 == 1) {$weight4 = 34;}
if ($randomweight4 == 2) {$weight4 = 35;}
if ($randomweight4 == 3) {$weight4 = 36;}
if ($randomweight4 == 4) {$weight4 = 37;}
$randomgender4 = rand(1,2);
if ($randomgender4 == 1)
{
$gender4 = "Male";
}
else
{
$gender4 = "Female";
}
$randomintellect4 = rand(1,100);
$randomkeeness4 = rand(1,100);
$randomaggresiveness4 = rand(1,100);
?>
<div id="apDiv1">Banner</div>
<div id="apDiv2">
<table width="824" height="286" border="0">
<tr>
<td height="41" align="center">Dog 1</td>
<td align="center">Dog 2</td>
<td align="center">Dog 3</td>
<td align="center">Dog 4</td>
</tr>
<tr>
<td height="239" valign="top"><p>Gender: <?php print $gender; ?><br>
Size: Small<br>
Weight: <?php print $weight; ?>
</p>
<p>Speed: 5<br>
Endurance: 1<br>
Stamina: 1<br>
Strength: 1</p>
<p>Intellect: <?php print $randomintellect; ?><br>
Keeness: <?php print $randomkeeness; ?><br>
Aggresiveness: <?php print $randomaggresiveness; ?>
</p>
<p> <br>
</p></td>
<td valign="top"><p>Gender: <?php print $gender2; ?><br>
Size: Medium-Small<br>
Weight: <?php print $weight2; ?>
</p>
<p>Speed: 1<br>
Endurance: 5<br>
Stamina: 1<br>
Strength: 1</p>
<p>Intellect: <?php print $randomintellect2; ?><br>
Keeness: <?php print $randomkeeness2; ?><br>
Aggresiveness: <?php print $randomaggresiveness2; ?>
</p></td>
<td valign="top"><p>Gender: <?php print $gender3; ?><br>
Size: Medium<br>
Weight: <?php print $weight3; ?>
</p>
<p>Speed: 1<br>
Endurance: 1<br>
Stamina: 5<br>
Strength: 1
</p>
<p>Intellect: <?php print $randomintellect3; ?><br>
Keeness: <?php print $randomkeeness3; ?><br>
Aggresiveness: <?php print $randomaggresiveness3; ?>
</p></td>
<td valign="top"><p>Gender: <?php print $gender4; ?><br>
Size: Big<br>
Weight: <?php print $weight4; ?>
</p>
<p>Speed: 1<br>
Endurance: 1<br>
Stamina: 1<br>
Strength: 5</p>
<p>Intellect: <?php print $randomintellect4; ?> <br>
Keeness: <?php print $randomkeeness4; ?><br>
Aggresiveness: <?php print $randomaggresiveness4; ?>
</p></td>
</tr>
</table>
<table width="823" border="0">
<tr>
<td width="174" height="26" align="center"><?php print "<a href='firstdog.php?chosendog=1&randomintellect=$randomintellect&randomkeeness=$randomkeeness&randomaggresiveness=$randomaggresiveness&weight=$weight&gender=$gender'> Buy Dog </a>" ?></td>
<td width="171" align="center"><?php print "<a href='firstdog.php?chosendog2=1'> Buy Dog </a>" ?></td>
<td width="285" align="center"><?php print "<a href='firstdog.php?chosendog3=1'> Buy Dog </a>" ?></td>
<td width="175" align="center"><?php print "<a href='firstdog.php?chosendog4=1'> Buy Dog </a>" ?></td>
</tr>
</table>