This topic is locked

Return true and false

12/5/2008 6:49:12 PM
PHPRunner General questions
U
Urnso author

[codebox]

If (($values["Completed"] == True) AND ($values["TimeToComplete"] == "")){

Echo "<font color=red><strong>If job is complete please enter time to complete. Record not updated.</strong></font>";

}

return false;
If ($values["Completed"] == True){

$values["CompletedBy"] = $_SESSION["UserID"];

$values["CompletedDate"] = now();

}

If ($values["Completed"] == False){

$values["CompletedBy"] = "";

$values["CompletedDate"] = "";

}

return true;

[/codebox]
Using this code if the user checks completed but forgets to enter time the message is shown on the page and no update is made.
If they go back and enter the time and leave the completed box checked. It will not update the record. Do I have a format wrong on this somewhere?

J
Jane 12/8/2008

Hi,
see my chnages in Bold:

If ($values["Completed"] && !$values["TimeToComplete"]){

Echo "<font color=red><strong>If job is complete please enter time to complete. Record not updated.</strong></font>";

return false;

}
If ($values["Completed"]){

$values["CompletedBy"] = $_SESSION["UserID"];

$values["CompletedDate"] = now();

}

If (!$values["Completed"]){

$values["CompletedBy"] = "";

$values["CompletedDate"] = "";

}

return true;