1

I built a very small simple php() mail app to send sms messages to my staff from our portal. Strange thing is, it was working fine this morning, tested it on and off for a couple of hours, everything was fine. Then I left for the afternoon, came back and went back to make sure everything was still intact, and all of a sudden, the sms stopped working. Nothing was changed, the code was identical, I even re-uploaded the back-up I had from when it was working. Here is what I know:

The send_sms.php works fine if I run it straight from the browser, I just get an empty message, but everything else is there.

I have additional scripts in the page to display an error or success message, which it doesn't do either of, also a snippet to clear the textarea when submitted, they have all stopped working. I have researched this for hours, tried re-writing the send_sms.php, and the js, but can't get it to respond at all. So here is what I have:

HTML

<form id="sendsms" name="sendsms" method="post" action="send_sms.php">
      <p>
        <textarea name="text" cols="45" rows="5" id="text" maxlength="130"  placeholder="Type your Text here, 130 characters max" required="required"> </textarea><div class="res4 text-muted" id="charNum"><small></small></div>
      </p>
<button type="submit" id="test" name="submit" class="btn btn-warning btn-    sm">Send SMS</button>
<div class="formsuccess" id="sendsmsResponse">

</div>
</form>

here is the js

 $("#sendsms").submit(function(event) 
 {
     event.preventDefault();

     var $form = $( this ),
         $submit = $form.find( 'button[type="submit"]' ),
         message_value = $form.find( 'textarea[name="text"]' ).val(),
         url = $form.attr('action');


     var posting = $.post( url, {                           
                       text: message_value

                   });

     posting.done(function( data )
     {

         $( "#sendsmsResponse" ).html(data);

         $submit.text('Your text was sent.');

         $submit.attr("disabled", true);

        $('#sendsms')[0].reset();

   setTimeout(function() {
       $('#sendsmsResponse').fadeOut();
       $('#text').val('')
       }, 10000 );

  function enableButton(){
      $('#test').attr("disabled", false);
      $('#test').text('Send Text');
}

 setTimeout(enableButton, 10500);


     });
});

and here is the mail script

<?php

$text = $_POST['text'];


$to = "**********@vtext.com";
$subject = "Support";
$message = "$text";
$from = "*****@**********.net";
$headers = "From: $from";

if (mail($to,$subject,$message,$headers))


 {
        echo "<h5 class='alert alert-success res4'>Your text has been sent.     We will respond soon.</h5>";
    }

    else

  {
        echo "<h5 class='alert alert-danger res4'>Your text has NOT been     sent. Please try again.</h5>";
    }

?>

I just can't for the life of me figure out what happened to make it stop working, I have been trying to fix it for hours

  • Did you check the browser console for any errors ? – webNeat Jan 13 '17 at 09:54
  • For the js errors, have you checked your browser console? – ʰᵈˑ Jan 13 '17 at 09:54
  • See: http://stackoverflow.com/questions/38552125/my-email-to-text-sent-to-vtext-com-stopped-working *"It's all about revenue. If you were using Vtext, good chance you have been blocked by Verizon and they want you to purchase enterprise services."* – ʰᵈˑ Jan 13 '17 at 09:55
  • If it was working fine at one point and then stopped I might venture to guess that you're being either rate-limited or spam-blocked (most likely based on the IP address). Have you considered this? – Jonathan Gray Jan 13 '17 at 09:56
  • showing no errors – newbiecoder Jan 13 '17 at 09:56
  • I had considered it, but I figured in my previous business I had the same feature and used it for 5 years and never had any problems, the thing is, it still works if I runt it through the browser – newbiecoder Jan 13 '17 at 09:59
  • I just ran the console again, and it showed me this An invalid form control with name='' is not focusable. I'm not exactly sure what that means, sorry, still learning – newbiecoder Jan 13 '17 at 10:05
  • I went and looked over the post you linked to, I mean it is very possible, even though I just started doing it this morning, and only a handful of texts. I know the company that we sell prepaid cell services for, they are a small company, I asked the owner if they have enterprise servies with verizon, cause they mass text customers all a couple times a month, he said they didn't, and that their sms was still working from their portal....so I'm stumped – newbiecoder Jan 13 '17 at 10:21
  • I was rate-limited once by a Facebook API just from too much testing. Rate limiting detection can be quite advanced. For example you may be blocked for 24 hours just for sending 10 requests within 10 seconds depending on the resource you're interacting with. So it's not necessarily the amount of requests that you're sending, it could be simply that you've made (or allowed) the requests to be too close together. – Jonathan Gray Jan 13 '17 at 10:37
  • didn't think of that, I appreciate it! – newbiecoder Jan 13 '17 at 10:41
  • I went and researched the console error I was getting, An invalid form control with name='' is not focusable, I don't have any hidden fields, nothing is nested in Fieldset, so maybe I am blocked...cause I can't figure it out – newbiecoder Jan 13 '17 at 10:45
  • 1
    just a side note, I changed the $to in the mail script to an actual email address, and it still wouldn't work, so I am going to have to dig further into the invalid form control error, cause that's gotta be the culprit, thanks guys – newbiecoder Jan 13 '17 at 10:55

1 Answers1

0

I found the culprit, was just plain stupidity on my part. I added a small login form to my nav header, which I have as a php include on the page with the text submit form, and it was using the same <button type="submit">that I have on the sms form, as soon as I moved the login out of the header, everything worked fine. I'm an idiot, thanks for your input, I'll be sure to look everywhere next time.

  • To resolve that problem give the buttons unique id's or names and do a check for the correct submit button being pressed or direct one to another page (maybe the login - you can make that look natural by giving a logged in notice then just refresh the page back to where it came from) – CodingInTheUK Jan 13 '17 at 11:54
  • I just did exactly that, thanks Chris and everyone else! – newbiecoder Jan 13 '17 at 11:56