<?php
$to = "service@mysite.no";
$subject = "Reparasjon av " . $_REQUEST['type'] . " fra mysite.no";
$types = if(!empty($_REQUEST['type'])) {echo($_REQUEST['type'] . ". ");};
$reps = if(!empty($_REQUEST['rep'])) {echo($_REQUEST['rep']);};
$message = $types . . $reps . "\n\nKommentarer:\n" . $_REQUEST['kommentarer'] . "\n\nFra:\n" . $_REQUEST['navn'] . "\nTelefon: " . $_REQUEST['telefon'] . "\nEmail: " . $_REQUEST['email'] . "\nBosted: " . $_REQUEST['bosted'];
$headers = "From: " . $_REQUEST['email'] . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
if (mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $headers)) {
header( 'Location: http://www.mysite.no/' );
} else {
header( 'Location: http://www.mysite.no/' );
}
?>
It says there’s a T_IF error in line 4. What’s the problem?
You can’t use
ifthere, it’s a syntax error. Technicallyifis a statement, not an expression. That means you can’t use it in an assignment like$types = if (...).