I have a form which collects a user’s area code, exchange, station, and optional extension number. These variables are then used in an html mail script which emails those 3 or four fields to me. My mail script works fine as follows:
$to = 'firstname.lastname@example.org';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: my namee <email@example.com>' . "\r\n";
$subject = 'The subject line';
$message = "
mail($to, $subject, $message, $headers);
But, because the $_POST['extension'] variable may not contain any characters, I thought I’d dress-up my script by writing an “if-then” statement that says something like
if (strlen($_POST['extension']) > 0 then the output should be
areacode-exchange-station ext nnn (where nnn is the optional extension number that may or may not be provided) and if the strlen($_POST['extension']) is < 1 then the output should be simply
I have tried every combination of writing an if-then statement and escaping the quotes that I am ashamed to admit how much time I’ve wasted.
Might someone provide direction?