Hi,

I'm having problems with a chunk of 'rogue' code that does not perform as 
expected (it does not pass the expected date, but an empty value). Most of 
the time, it works - so I'm wondering whether it might be a browser issue. 
(The latest failure occurred with Firfeox 3.0 browser on an NT 5.1 OS.) The 
code is stored on an Unix server, running PHP 5.x. 

I've isolated it down to multiple if - elseif statements that check long dates 
for completeness, "day" "month" and "year". The code then applies it results 
printing one of following: the full date - 22 May 2009, month-year - May 
2009, or just the year, 2009. My question is whether the ORDER of checking is 
important, i.e, whether checking for the null sets BEFORE full sets or AFTER. 

I've added debugging code to be able to get the raw POST values so I can 
manually enter it into the db, but I would really appreciate some help here. 
The code is old -- I wrote it seven years ago, and had worked well until I 
modified it, but I no longer have the original working code. 

[The first conditional line of the code checks whether the user has entered 
the birth date, then it checks for the death date. The $_SESSION stuff is 
debugging code.]


<?php


        $yd = $_POST['death'];
        $yb =  $_POST['birth']; 


        if ($_POST['bday'] == "Day" && $_POST['bmonth'] == "Month" && 
$_POST['birth'] 
== "Year") {
        
                
                if ($_POST['dday'] != "Day" && $_POST['dmonth'] != "Month" && 
$_POST['death'] != "Year") {
                                        
                        $_POST['rdod'] = ("{$_POST['dday']} {$_POST['dmonth']} 
{$_POST['death']}");
                        $_SESSION['ALL1rdod'] = $_POST['rdod'];
        
                }
        
                
                elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] == "Month" 
&& 
$_POST['death'] != "Year") {
                                        
                        $_POST['rdod'] = $_POST['death'];
                        $_SESSION['YEAR1rdod'] = $_POST['rdod'];
        
                }
        
                
                elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] != "Month" 
&& 
$_POST['death'] != "Year") {
                                        
                        $_POST['rdod'] = ("{$_POST['dmonth']} 
{$_POST['death']}");
                        $_SESSION['MONTHYEAR1rdod'] = $_POST['rdod'];
        
                }


                $_SESSION['Sdebugdod1'] = "{$_POST['dday']} {$_POST['dmonth']} 
{$_POST['death']}";
                        
        }
        
        
                else {
                
                
                        if ($yd > $yb) {
                                
                
                                if ($_POST['bday'] != "Day" && $_POST['bmonth'] 
!= "Month" && 
$_POST['birth'] != "Year") {
                
                                        $_POST['rdob'] = ("{$_POST['bday']} 
{$_POST['bmonth']} 
{$_POST['birth']}");
        
                                }
        
                
                                elseif ($_POST['bday'] == "Day" && 
$_POST['bmonth'] == "Month" && 
$_POST['birth'] != "Year") {
                                        
                                        $_POST['rdob'] = $_POST['birth'];
        
                                }
        
                
                                elseif ($_POST['bday'] == "Day" && 
$_POST['bmonth'] != "Month" && 
$_POST['birth'] != "Year") {
                                        
                                        $_POST['rdob'] = ("{$_POST['bmonth']} 
{$_POST['birth']}");
        
                                }
                                
                
                
                                if ($_POST['dday'] != "Day" && $_POST['dmonth'] 
!= "Month" && 
$_POST['death'] != "Year") {
                                        
                                        $_POST['rdod'] = ("{$_POST['dday']} 
{$_POST['dmonth']} 
{$_POST['death']}");
                                        $_SESSION['ALL2rdod'] = $_POST['rdod'];
        
                                }
        
                
                                elseif ($_POST['dday'] == "Day" && 
$_POST['dmonth'] == "Month" && 
$_POST['death'] != "Year") {
                                        
                                        $_POST['rdod'] = $_POST['death'];
                                        $_SESSION['YEAR2rdod'] = $_POST['rdod'];

                                }
        
                
                                elseif ($_POST['dday'] == "Day" && 
$_POST['dmonth'] != "Month" && 
$_POST['death'] != "Year") {
                                        
                                        $_POST['rdod'] = ("{$_POST['dmonth']} 
{$_POST['death']}");
                                        $_SESSION['MONTHYEAR2rdod'] = 
$_POST['rdod'];
        
                                }


                                $_SESSION['Sdebugdod2'] = "{$_POST['dday']} 
{$_POST['dmonth']} 
{$_POST['death']}";

                                
        
                        }


?>

Any help or pointers would be greatly appreciated!

Tia,
Andre


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to