Forum Moderators: coopster

Message Too Old, No Replies

webform to sms

I need help with my script

         

afterburner

3:40 pm on Feb 21, 2004 (gmt 0)

10+ Year Member



I wrote a small php script that I thought would send a sms message to my cell phone and my email as soon as the form was filled out. What happens is that I get two emails instead of one email and and one sms text message. Can anyone help me on this?

Here is the code I am using. Thanks in advance

<?
$smsto="717*******@vtext.com";
$subject="Hi!";
$meslength="160";
?>
<? if ($action==send) {
if ($fromemail==""){ $fromemail="My SMS"; }
$bodytext="$message";
$body="$bodytext";
if (strlen($body)>$meslength) {
$newbody = wordwrap($body, $meslength, "<br>");
$barr = explode("<br>", $newbody);
$count=count($barr);
for($i = 0; $i < $count; $i++) {
$i2=$i+1;
$barr[$i]="($i2/$count) \n $barr[$i]";
// echo"$barr[$i]<br>";
mail($smsto, $subject, $barr[$i], "From: $fromemail");
}
}
else
{
mail($smsto, $subject, $body, "From: $fromemail");
}
echo"<p class=text1><i>Thanks, your message have been sent!</i></p>";
}
?>

Timotheos

4:30 pm on Feb 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You do have the mail function in the for loop so depending on the value of $count you're going to be sending the email that many times.

afterburner

4:46 pm on Feb 21, 2004 (gmt 0)

10+ Year Member



I do get two emails but what I am shooting for is one email and one sms message. I am not a programmer so this is all foreign to me.
Thanks