Okay, I am just going to show the whole script. it's not too long and I will explain at the end...
<?php
include 'connect.php';
include 'header.php';
if(!isset($_COOKIE['member_id']))
die('<p>You\'re not logged in, please <a href=index.php>login</a></p>');
?>
<script>
$(document).ready(function(){
$("form#FightForm").submit(function() {
// we want to store the values from the form input box, then send via ajax below
var mname = $('#mname').attr('value');
$.ajax({
type: "POST",
url: "fight.php",
data: "Name="+ mname,
success: function(){
$('form#FightForm').hide(function(){$('div#FightDiv').load("fight.php");});
}
});
return false;
});
});
</script>
<?php
print"<div id=\"FightDiv\">";
if($Post['Fight']){
$Name=$_post['Name'];
print"$Name";
}
print"</div>";
echo "<form id=\"FightForm\" method=\"post\">";
echo "<p>Name - Level<br /></p>";
echo "<p><select id=\"mname\" class=\"select\" name='Name'>";
if($_COOKIE['Monstername'])
{
$Name = $_COOKIE['Monstername'];
$Query = mysql_query("SELECT * from Monsters where Name='$Name' limit 1") or die("ZOMG no cookie monster");
$QMonster = mysql_fetch_array($Query);
if($QMonster['Zone'] == $Zoneloc)
echo "<option value=\"$_COOKIE[Monstername]\">$_COOKIE[Monstername] (Previous fight)</option>";
}
$Monster1 = "SELECT * from Monsters order by Level asc";
$Monster2 = mysql_query($Monster1) or die("Could not select Monsters from under your bed!");
while ($Monster3 = mysql_fetch_array($Monster2))
{
echo "<option value=\"$Monster3[Name]\">$Monster3[Name] - $Monster3[Level]</option>";
}
echo "</select><br />";
echo "<input class=\"button\" type=\"submit\" name=\"Fight\" value=\"Fight Monster\" /></p></form><br />";
?>
</body>
</html>
Now when ever I submit the form it just loads the fight.php without a submit as if I am just loading the page.
How can I get it to Post['Fight'] into the div? It just isn't making sense to me...