I am using the code below for sending web mails and sms notifications. It works perfectly fine but I would like to ONLY receive the SMS when users choose “A” value from the servicerequired drop-down menu and also don’t want to receive SMS from 8PM to 5AM.
Any help is highly appreciated..
<form action="/thankyou.php" name="form1" method="post" >
<input type="hidden" name="curtime" />
<select name="servicerequired">
<option selected="selected" value="">Please Choose</option>
<option value="A">Replacement</option>
<option value="B">Architectural</option>
<option value="C">Commercial</option>
<option value="other">Other</option>
</select>
<input type="submit" value="submit" name="submit" />
and Here is PHP part
if ($_POST['submit']) {
$to="myemail@mydomain.com";
$sms="mymobilenumber@domain.net";
$subject="Online Quote";
$from = "webmaster@mydomain.com";
$curtime = $_REQUEST['curtime'] ;
$service = $_REQUEST['servicerequired'] ;
$curtime = date("Y-m-d H:i:s");
$headers = "From: $from
" .
"MIME-Version: 1.0
" .
"Content-Type: multipart/mixed;
" .
" boundary=\"{$mime_boundary}\"";
$message="message to email";
$message2="message to sms";
@mail($to, $subject, $message, $headers);
@mail($sms, $subject, $message2, $headers);
ANS below - special thanks to @Dagon :
if ($_POST['submit']) {
$to="myemail@mydomain.com";
$sms="mymobilenumber@domain.net";
$subject="Online Quote";
$from = "webmaster@mydomain.com";
$curtime = $_REQUEST['curtime'] ;
$service = $_REQUEST['servicerequired'] ;
$curtime = date("Y-m-d H:i:s");
$headers = "From: $from
" .
"MIME-Version: 1.0
" .
"Content-Type: multipart/mixed;
" .
" boundary=\"{$mime_boundary}\"";
$message="message to email";
$message2="message to sms";
@mail($to, $subject, $message, $headers);
if($_POST['servicerequired']=='A' && (date("G")>5 && date("G")<20) ){
@mail($sms, $subject, $message2, $headers);
}
if($_POST['servicerequired']=='A' && (date("G")>5 && date("G")<19) ){
//SMS STUFF
}