Jump to content


Photo

Running If / Else statements


  • Please log in to reply
1 reply to this topic

#1 indalecio

indalecio
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 05 July 2006 - 08:04 AM

This DOES use phpBB, but thats not the concern.  I am trying to get this If / Else statement to read the $problem variable, but for some reason it just doesn't to, and it moves onto the item creation.  I have tried this current setup, isset(), and !isset(). 

Any help is appreciated.


/////////////

// Weapons //

/////////////



	if ( $_POST['equipment_type'] == 'weapon' ) {

		if ( isset($_POST['submit']) ) {

			if ( !isset($_POST['weapon_name']) ) {
				$problem = '1';
				$problem_statement = 'Your weapon did not have a name<br>';
			}
			if ( !isset($_POST['weapon_type']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'Your weapon did not have a type<br>';
			}
			if ( !isset($_POST['weapon_job1']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'Your weapon did not have a class<br>';
			}
			if ( !isset($_POST['weapon_job1']) && isset($_POST['weapon_job2']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'There was a problem with the classes you chose.<br>';
			}
			if ( !isset($_POST['weapon_job1']) && !isset($_POST['weapon_job2']) && isset($_POST['weapon_job3']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'There was a problem with the classes you chose.<br>';
			}
			if ( !isset($_POST['weapon_dmg_low']) && !isset($_POST['weapon_dmg_hi']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'Your weapon is missing a damage parameter.<br>';
			}
			if ( !isset($_POST['weapon_lvl']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'Your weapon is missing the level parameter.<br>';
			}
			if ( !isset($_POST['weapon_cost']) ) {
				$problem = '1';
				$problem_statement = $problem_statement . 'Your weapon is missing the cost parameter.<br>';
			}
			if ( !isset($_POST['weapon_weight']) ) {
				$_POST['weapon_weight'] = '0';
			}
			if ( !isset($_POST['weapon_def']) ) {
				$_POST['weapon_def'] = '0';
			}

			if ($problem == '1') {
			
				if ( $_POST['weapon_hands'] == '1' ) {

					$template->set_filenames(array(
					'body' => 'admin/weapon_add_one.tpl')
					);
					
					$template->assign_vars(array( 
					'PROBLEM_STATEMENT' => $problem_statement ) 
  		      			); 
				
				} elseif ( $_POST['weapon_hands'] == '2' ) {

					$template->set_filenames(array(
					'body' => 'admin/weapon_add_two.tpl')
					);

					$template->assign_vars(array( 
					'PROBLEM_STATEMENT' => $problem_statement ) 
  		      			);
				} 
			
			} else {
			
			
		/****************************
 		* Insert weapon to database *
 		*****************************/
		
				$update = DATABASE INFO
 

				if (!$update) {

					message_die(GENERAL_MESSAGE, 'Your weapon could not be added.' );

				}


				$success = TRUE;

			}
			
		} else {



		/************************
 		* Go to Add weapon Page *
 		*************************/
			if ( $_POST['weapon_hands'] == '1' ) {


				$template->set_filenames(array(

					'body' => 'admin/weapon_add_one.tpl' )
				);
				
			} elseif ( $_POST['weapon_hands'] == '2' ) {


				$template->set_filenames(array(

					'body' => 'admin/weapon_add_two.tpl' )

				);
			} 

	

			$template->assign_vars(array( 

				'FORM_ACTION' => append_sid("admin_equipment.$phpEx") )
						
        		); 

		}




#2 Mr.x

Mr.x
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 06 July 2006 - 04:52 AM

Try this, not 100% sure. Probley too simple to be true!

Replace the following section, if it doesn't imideatly work then change it back..

if ($problem == '1') {
			
				if ( $_POST['weapon_hands'] == '1' ) {

					$template->set_filenames(array(
					'body' => 'admin/weapon_add_one.tpl')
					);
					
					$template->assign_vars(array( 
					'PROBLEM_STATEMENT' => $problem_statement ) 
  		      			); 
				
				} elseif ( $_POST['weapon_hands'] == '2' ) {

					$template->set_filenames(array(
					'body' => 'admin/weapon_add_two.tpl')
					);

					$template->assign_vars(array( 
					'PROBLEM_STATEMENT' => $problem_statement ) 
  		      			);
				 
			
			} else {





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users