Jump to content

Recommended Posts

Can't seem to get

if($x && $m){

if($x &! $y)

to work, any help would be appreciated. This code uses a radio button and a text box for the numbers to add to the variables...

 

if($_POST['option']){
$opts = $_POST['option'];
foreach ($opts as $o) {
if($o == 1){
if($y &! $x){
if($y &! $m){$page1=1;
echo "You lost " . $z . " Dollars.<br />";}}
if($x &! $y){
if($x &! $m){$page1=1;
echo "You lost " . $d . " Euros.<br />";}}
if($x && $y){
if($x &! $m){$page1=1;
echo "You lost " . $zz . " Pence.<br />";}}
if($x && $m){
if($x &! $y){$page1=1;
echo "You lost " . $d . " Francs.<br />";}}}
if($x && $y && $m){$page1=1;
echo "You lost " . $zzz . " Yen.<br />";}}

Link to comment
https://forums.phpfreaks.com/topic/156879-solved-if-issues/
Share on other sites

PHP Code Page (with other code)

$y = $_REQUEST['y'];
$x = $_REQUEST['z'];
$m = $_REQUEST['m'];

Main Page that sends the request to the code page.

<input name="z" type="text" /><br>
<input name="y" type="text" /><br>
<input name="m" type="text" /><br>

Mind you this is a test, so variable names mean nothing right now...

Link to comment
https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-826434
Share on other sites

here u forgot a bracket to end the first if statment

<?php
if($_POST['option']){
$opts = $_POST['option'];
foreach ($opts as $o) {
	if($o == 1){
		if($y &! $x){
			if($y &! $m){
				$page1=1;
				echo "You lost " . $z . " Dollars.<br />";
			}
		}
		if($x &! $y){
			if($x &! $m){
				$page1=1;
				echo "You lost " . $d . " Euros.<br />";
			}
		}
		if($x && $y){
			if($x &! $m){
				$page1=1;
				echo "You lost " . $zz . " Pence.<br />";
			}
		}
		if($x && $m){
			if($x &! $y){
				$page1=1;
				echo "You lost " . $d . " Francs.<br />";
			}
		}
	}
	if($x && $y && $m){
		$page1=1;
		echo "You lost " . $zzz . " Yen.<br />";
	}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-826455
Share on other sites

&! works just the same as && !(var)

 

After some work on it, I discovered that $m had to be in front for the rest of it to function.

 

if($m && $y){
if($m &! $x){$page1=1;
echo "You lost " . $zz . " Pence.<br />";}}
if($m && $x){
if($m &! $y){$page1=1;
echo "You lost " . $d . " Francs.<br />";}}

Link to comment
https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-827137
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.