Cetanu Posted August 26, 2009 Author Share Posted August 26, 2009 Reworded question: I am trying to make this code subtract a value from a session, echo it, and keep doing that until it reaches 0. I am using a form that says "Do you want to attack? or Flee?" when they click attack, ideally I would like the form to disappear, the values to be updated, and then echoed again. If they click flee I want it to use a header() to send them back to the main page. My problem is, that after clicking "Attack" the page doesn't execute code it just reloads itself. here is the code that I believe to be the suspect of the matter: <?php if(!$_POST['confirm']){ echo "<form action='fcenter.php?page=planet1' method='post'> <input type='radio' name='attack' value='Attack'/>Attack<br/> <input type='radio' name='attack' value='Flee'/> Flee <br/> <input type='submit' name='confirm' value='Choose'/> </form> "; } if(isset($_POST['confirm'])){ if($_POST['attack']=="Attack"){ $i = $row['attack']; if(intval($i) > 20){ $dam = $row['attack']-$_SESSION['defenseDrone']; $_SESSION['healthDrone']=$_SESSION['healthDrone']-$dam; echo "Testing HellO! ".$_SESSION['healthDrone']; } if(intval($i) < 20){ echo "Hi"; } } else if($_POST['attack']=="Flee"){ echo "Hi"; } } ?> I'm not sure if the form is wrong or something, but it still, nonetheless, refuses to cooperate. Link to comment https://forums.phpfreaks.com/topic/171729-confusing-question/page/2/#findComment-906742 Share on other sites More sharing options...
Bendude14 Posted August 27, 2009 Share Posted August 27, 2009 that code works ok for me. you are selecting a radio button before submitting the form right? Maybe you should add a default selection. just add this to the default radio button selected="selected" Also add error_reporting(E_ALL) see if you get any errors... Link to comment https://forums.phpfreaks.com/topic/171729-confusing-question/page/2/#findComment-907587 Share on other sites More sharing options...
Cetanu Posted August 27, 2009 Author Share Posted August 27, 2009 It probably works okay because you weren't logged in like a member of the site would be . Anyway, yeah I want them to select an option for the <select> form and then after some code is executed, I want them to select a radio button. However, after the user gets to the radio thing and selects (and presses "Confirm") the page doesn't move onto other code, it just reloads itself. Link to comment https://forums.phpfreaks.com/topic/171729-confusing-question/page/2/#findComment-907669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.