Forums

(not so) simple If statement

olaeblue 02 Nov, 2011
I want to run a simple if statement on a form to generate the email content. The email even is triggered after the DB save.

TEST
<?php
$user =& JFactory::getUser();
?>
<?php if ({$form->data['for']}<>"Self") 
  {
  echo "<p>This booking has been made by ";
  echo $user->name;
  echo " on behalf of {name}";
  }
else
{$echo "not worked";)
?>


for is a drop down list which has "Self" as a value & name is a text box.

The text I get is

TEST data[`for`]}<>"Self") { echo "

This booking has been made by "; echo $user->name; echo " on behalf of MyName"; } else {echo "not worked";) ?>

Sorry I know there is something obvious but gone code blind :-(
Uclabruins 03 Nov, 2011
I'm not a PHP guru, but here are some things to try

Maybe try to change:

({$form->data['for']}<>"Self") 

to:

({$form->data['for']}=="Self") 

and see if that works.

If that doesn't work/you know the <> is correct, the next step would be to close the '{' you opened after "else". ETA: I just looked at it again and it looks like this is probably the issue. I don't know if you're supposed to use '()' or '{}' but it looks like a typo since the opening and closing is different.
This topic is locked and no more replies can be posted.