PHP: Trying to send an email form with variables and an IF statement -


i trying make email change depending on variables available.

there total of 6 operation id's, 20 (the 1 shown below in code) requires machine code unlike other operations.

$email =  if ($operationid == 20)     {         'machine: '.$machcode."\r\n".     } "jobid: ".$jobid."\r\n" .  "partid: ".$part_id."\r\n" . "\nnote: ".$message."\r\n"; @mail($email_to, $email_subject, $email);  

if 'if statement' not there email can sent looks following

machine: jobid: 123456789 partid: 123456789 note: test 

i not want there blank space next 'machine'. want machine line removed unless, obviously, operationid 20. email looks following:

jobid: 123456789 partid: 123456789 note: test 

how make machine line activated when operation equal 20?

i error

`parse error: syntax error, unexpected t_if in /var/www/ps_t/send_form_email.php on line 21 call stack: 0.0004 656768 1. {main}() /var/www/ps_t/punch.php:0` code used above.

thanks in advance.

try code

$email = ""; if ($operationid == 20) {      $email .= 'machine: '.$machcode."\r\n"; } $email .= "jobid : ".$jobid."\r\n" .            "partid: ".$part_id."\r\n" .           "\nnote: ".$message."\r\n"; @mail($email_to, $email_subject, $email);  

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -