Ok, I am a total noob at PHP. This is like my first go editing it. I have this to send sms messages to phones: <?php $mobileNumber = $_POST['mobileNumber']; $message = $_POST['message']; $count = $_POST['count']; $provider = $_POST['provider']; for ($i = 0; $i < $count; $i++) { $headers = "From: info@security-hackers.org \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; $subject = "Sub"; $body = $message; $email = $mobileNumber . "@" . $provider; if (mail($email, $subject, $body, $headers)) { echo "You have sent <b>$count</b> SMS messages to $mobileNumber"; } else { exit(0); } } ?> Code (markup): That one works and sends to any number. I want to have it to where I can block it from sending it to a few numbers. I tried to do this but it didn't work. <?php $mobileNumber = $_POST['mobileNumber']; $message = $_POST['message']; $count = $_POST['count']; $provider = $_POST['provider']; for ($i = 0; $i < $count; $i++) { $headers = "From: info@security-hackers.org \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; $subject = "Sub"; $body = $message; $email = $mobileNumber . "@" . $provider; if ($mobileNumber = '1234567890') { echo "You cannot send to this number." exit(0); } elseif(mail($email, $subject, $body, $headers)) { echo "You have sent <b>$count</b> SMS messages to $mobileNumber"; } else { exit(0); } } ?> Code (markup): What I am trying to do is get it to send to any number but a few ones that I do not want people to send to. Anyone got any Ideas on what I am doing wrong?
Change: if ($mobileNumber = '1234567890') Code (markup): to if ($mobileNumber == '1234567890') Code (markup): One equal sign for assignment, two for comparison. The way you have it, it sets the value of $mobileNumber to '1234567890', and then checks whether the entire expression evaluates as true, so it is probably blocking all numbers from working.
If you want to send SMS via PHP, don't you need a SMS gateway? If you got one, is it expensive? I can't see how your script can send something via any gateways..
No you don't necessarily need a sms gateway you can use most provider's mms address or sms address like sending a sms through email thats all.
In receiver-pays countries (like USA), mobile phone companies often provide free email gateways for SMS.
ok This works fine, thank you guys. if ($mobileNumber == '1234567890') { echo "You cannot send to this number." ; } elseif (mail($email, $subject, $body, $headers)) { echo "You have sent <b>$count</b> SMS messages to $mobileNumber"; } else { exit(0); } } Code (markup): But when I try to add multiple phone numbers that cannot be sent to, the script doesn't work. if ($mobileNumber == '1234567890' , '11234567890' , '2134375876' ) { echo "You cannot send to this number." ; } elseif (mail($email, $subject, $body, $headers)) { echo "You have sent <b>$count</b> SMS messages to $mobileNumber"; } else { exit(0); } } Code (markup): thank you
like this if (($mobileNumber == '1234567890') OR ($mobileNumber == '1234567890') OR ($mobileNumber == '1234567890')) { echo "You cannot send to this number." ; } elseif (mail($email, $subject, $body, $headers)) { echo "You have sent <b>$count</b> SMS messages to $mobileNumber"; } else { exit(0); } } PHP:
or use this $bannednum = array("1234567890", "12234567890", "12434567890", "1235567890"); if (in_array($mobileNumber, $bannednum)) { echo "You cannot send to this number." ; } elseif (mail($email, $subject, $body, $headers)) { echo "You have sent <b>$count</b> SMS messages to $mobileNumber"; } else { exit(0); } } PHP: