Jump to content

Confusing Question


Cetanu

Recommended Posts

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.

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...

It probably works okay because you weren't logged in like a member of the site would be  :P .

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.