if statement prblem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
akkad
Forum Newbie
Posts: 14
Joined: Tue Jul 31, 2007 4:09 am

if statement prblem

Post by akkad »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi again,

i am sending information using this form to the body.php file.

Code: Select all

<?php
echo" <FORM style=PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px 
name=FormDateFilter mehtod=post action=body.php target=body>"; 

 echo"<SELECT class=formfield name=day> 
			  <OPTION value='' selected>- Day -</OPTION>
              <OPTION value=01>01</OPTION> <OPTION value=02>02</OPTION> 
              <OPTION value=03>03</OPTION> <OPTION value=04 >04</OPTION>
			  <OPTION value=05>05</OPTION> 
			  <OPTION value=06>06</OPTION> <OPTION value=07>07</OPTION> <OPTION 
              value=08>08</OPTION> <OPTION value=09>09</OPTION> <OPTION 
              value=10>10</OPTION> <OPTION value=11>11</OPTION> <OPTION 
              value=12>12</OPTION> 
              <OPTION value=13>13</OPTION> <OPTION value=14>14</OPTION> 
              <OPTION value=15>15</OPTION> <OPTION value=16 >16</OPTION>
			  <OPTION value=17>17</OPTION> 
			  <OPTION value=18>18</OPTION> <OPTION value=19>19</OPTION> <OPTION 
              value=20>20</OPTION> <OPTION value=21>21</OPTION> <OPTION 
              value=22>22</OPTION> <OPTION value=23>23</OPTION> <OPTION 
              value=24>24</OPTION>
			  <OPTION value=25>25</OPTION> 
			  <OPTION value=26>26</OPTION> <OPTION value=27>27</OPTION> <OPTION 
              value=28>28</OPTION> <OPTION value=29>29</OPTION> <OPTION 
              value=30>30</OPTION> <OPTION value=31>31</OPTION> </SELECT> 
			  
          <SELECT class=formfield name=month>
			  <OPTION value='' selected>- Month -</OPTION>		  
              <OPTION value=01>Jan</OPTION> <OPTION value=02>Feb</OPTION> 
              <OPTION value=03>Mar</OPTION> <OPTION value=04 
              >Apr</OPTION> <OPTION value=05>May</OPTION> <OPTION 
              value=06>Jun</OPTION> <OPTION value=07>Jul</OPTION> <OPTION 
              value=08>Aug</OPTION> <OPTION value=09>Sep</OPTION> <OPTION 
              value=10>Oct</OPTION> <OPTION value=11>Nov</OPTION> <OPTION 
              value=12>Dec</OPTION> </SELECT>
           <SELECT class=aws_formfield name=year> 
			<OPTION value='' selected>- Year -</OPTION>			
            <OPTION value=2006>2006</OPTION>
            <OPTION value=2007>2007</OPTION>
			 </SELECT>
           <INPUT class=aws_button type=submit value=OK>";
?
---------------------body.php---------------------

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', True);

$userid = $_COOKIE['cookie']['user'];
#echo $userid;
echo"<BR>";
if(!isset($day) && !isset($month) && !isset($year))
{
$day="";
$month="";
$year="";
}

if(!isset($day) && !isset($month) && isset($year))
{
$date=$year;
echo $date;
echo shell_exec("cat `bash ./cal $date` | grep akadi_icho |  /usr/bin/perl   /opt/lampp/htdocs/xampp/thesis/calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html");

}
if(!isset($day) && isset($month) && isset($year))
{

$date=$year."-".$month;
echo $date;
echo shell_exec("cat `bash ./cal $date` | grep akadi_icho | /usr/bin/perl   /opt/lampp/htdocs/xampp/thesis/calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html");

}


if(isset($day) && isset($month) && isset($year))
{
$date=$year."-".$month."-".$day;
echo shell_exec("cat `bash ./cal $date` | grep akadi_icho | /usr/bin/perl   /opt/lampp/htdocs/xampp/thesis/calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html");
#echo $date;
}
?>
i want to get mothly report and daily report and yearly report.

so i have used 4 if statements
the first one is the default [s]coz[/s] BECAUSE i want by default the page to be empty.

the problem is that only the last if is working i don't know why?


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please use

Code: Select all

tags when posting php code. e.g.

Code: Select all

<?php phpinfo(); ?>
see also: faq.php?mode=bbcode

If you do not select anything from your select elements the browser will pass an empty string as value and php will create a variable with an empty string as value, too.

Code: Select all

$s = ''; // empty string
echo isset($s) ? 'is set' : 'not set';
Your script relies on register_globals which is deprecated for quite some time now
http://de2.php.net/ChangeLog-4.php wrote:Version 4.2.0
22-Apr-2002

* ATTENTION!! register_globals defaults to 'off' now !!!
see also:
http://de2.php.net/security.globals
Post Reply