Jump to content

My IF Statement - Small Code


MoFish

Recommended Posts

hello. im trying to simply go into the correct if statement when the button is clicked depending of the value of $PlayerNumber.

 

I keep getting the "error again oops" and dont know the reason behind it.

 

here is the code im using.

 

you can see the page layout here http://www.mofish.co.uk/site-image.JPG showing $PlayerNumber contains a value.

 

any ideas why this is doing this?

 

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

	if($PlayerNumber == "4"){
		echo "4 players";
	} elseif($PlayerNumber == "5"){
		echo "5 players";
	} elseif($PlayerNumber == "6"){
		echo "6 players";
	} elseif($PlayerNumber == "7"){
		echo "7 players";
	}else {
		echo "error again... grr";
	}

} else {

echo '<div class="yellowheading">Can You Confirm That <b>' . $PlayerNumber . '</b> Players Played In This Event With A Buy In Of <b>' . $BuyInPrice . '</b> pounds</div>

<form action="" method="post" name="SubmitDetails">
	<div class="paddingdiv">1st : ' . $Player1Name . '</div>
	<div class="paddingdiv">2st : ' . $Player2Name . '</div>
	<div class="paddingdiv">3st : ' . $Player3Name . '</div>
	<div class="paddingdiv">4st : ' . $Player4Name . '</div>
	<div class="paddingdiv">5st : ' . $Player5Name . '</div>
	<div class="paddingdiv">6st : ' . $Player6Name . '</div>
	<div class="paddingdiv">7st : ' . $Player7Name . '</div>
	<div class="redheading"><b>Warning :</b> Clicking This Button Will Begin The Processing</div>
	<div class="paddingdiv"><input name="DoReport" type="submit" value="Confirm And Complete" /></div>
</form>';
}

Link to comment
Share on other sites

extract($_POST);

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

 

if($PlayerNumber == "4"){

echo "4 players";

} elseif($PlayerNumber == "5"){

echo "5 players";

} elseif($PlayerNumber == "6"){

echo "6 players";

} elseif($PlayerNumber == "7"){

echo "7 players";

}else {

echo "error again... grr";

}

 

} else {

 

<form action="" method="post" name="SubmitDetails">

           <input type="hidden" name="PlayerNumber" value="<?php echo $PlayerNumber; ?>"; <div class="paddingdiv">1st : ' . $Player1Name . '</div>

<div class="paddingdiv">2st : ' . $Player2Name . '</div>

<div class="paddingdiv">3st : ' . $Player3Name . '</div>

<div class="paddingdiv">4st : ' . $Player4Name . '</div>

<div class="paddingdiv">5st : ' . $Player5Name . '</div>

<div class="paddingdiv">6st : ' . $Player6Name . '</div>

<div class="paddingdiv">7st : ' . $Player7Name . '</div>

<div class="redheading"><b>Warning :</b> Clicking This Button Will Begin The Processing</div>

<div class="paddingdiv"><input name="DoReport" type="submit" value="Confirm And Complete" /></div>

</form>';

}

Link to comment
Share on other sites

extract($_POST);

thats SO unsecure...

 

switch($_POST[PlayerNumber]){
case "4":
  echo "4 players";
break;
case "5":
  echo "5 players";
break;
case "6":
  echo "6 players";
break;
case "7":
  echo "7 players";
break;
default:
  echo "error again... grr";
break;
}

Link to comment
Share on other sites

hiya again.

 

im having problems getting the values of declared variables at the top of my page within an if statement. I have the following declared at the top of my page which works and echo's my information fine.

 

name Boyd

overall buyin 5

overall minus 0

overall plus money 5

overall ballance 5

no 1st 0

no 2nd 1

percent 1st 0

percent 2nd 100

 

all these values are correct, so thats fine..

 

	$Player1OverallBuyin = $row_SelectPlayer1['OVERALLBUYIN'] + $BuyInPrice;
	$Player1OverallMinus = $row_Player1['MINUSMONEY'] - 0;
	$Player1PlusMoney = $row_SelectPlayer1['PLUSMONEY'] + $FirstPlaceWinnings;
	$Player1OverallMoney = $Player1OverallMinus + $Player1PlusMoney;
	$Player11st = $row_SelectPlayer1['1STPLACE'] + 1;
	$Player12nd = $row_SelectPlayer1['2NDPLACE'] + 0;
	$Player1GamesPlayed = $row_SelectPlayer1['GAMESPLAYED'] + 1;

 

however, inside my if statement once a button is clicked, I dont seem to have none of the values of these variables and they are all set to 0. why is this?

 

extract($_POST);
if (isset($_POST['DoReport'])){

if($PlayerNumber == "4"){
  
				echo "<div>name <b>" . $Player1Name . "</b></div>";
				echo "<div>overall buyin " . $Player1OverallBuyin . "</div>";
  				echo "<div>overall minus " . $Player1OverallMinus . "</div>";
  				echo "<div>overall plus money " . $Player1PlusMoney . "</div>";
  				echo "<div>overall ballance " . $Player1OverallMoney . "</div>";
  				echo "<div>no 1st " . $Player11st . "</div>";
  				echo "<div>no 2nd " . $Player12nd . "</div>";
  				echo "<div>percent 1st " . $Player1Percent1st . "</div>";
  				echo "<div>percent 2nd " . $Player1Percent2nd . "</div>";
} elseif($PlayerNumber == "5"){

 

this displays the following

 

name

overall buyin 0

overall minus 0

overall plus money 0

overall ballance 0

no 1st 1

no 2nd 0

percent 1st 100

percent 2nd 0

 

Link to comment
Share on other sites

at the top of the page outwith the if statement. here they are

 

$BuyInPrice = $_POST['BuyIn']; 
$PlayerNumber = $_POST['Players']; 

$Player1Name = $_POST['LstBox1']; 
$Player2Name = $_POST['LstBox2']; 
$Player3Name = $_POST['LstBox3']; 
$Player4Name = $_POST['LstBox4']; 
$Player5Name = $_POST['LstBox5']; 
$Player6Name = $_POST['LstBox6']; 
$Player7Name = $_POST['LstBox7']; 

$FirstPlaceWinnings = ($PlayerNumber * $BuyInPrice) - $BuyInPrice;
$SecondPlaceWinnings = $BuyInPrice;

			//player 1
$Player1OverallBuyin = $row_SelectPlayer1['OVERALLBUYIN'] + $BuyInPrice;
$Player1OverallMinus = $row_Player1['MINUSMONEY'] - 0;
$Player1PlusMoney = $row_SelectPlayer1['PLUSMONEY'] + $FirstPlaceWinnings;
$Player1OverallMoney = $Player1OverallMinus + $Player1PlusMoney;
$Player11st = $row_SelectPlayer1['1STPLACE'] + 1;
$Player12nd = $row_SelectPlayer1['2NDPLACE'] + 0;
$Player1GamesPlayed = $row_SelectPlayer1['GAMESPLAYED'] + 1;

Link to comment
Share on other sites

I use these values further up the page aswell; so cant really move them. I dont understand why the values are there in the variables; and then cleared as soon as i click the submit button. its as if its ignoring them all together.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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