1
votes

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

1
Did you check the browser console for any errors ? - webNeat
For the js errors, have you checked your browser console? - ʰᵈˑ
See: stackoverflow.com/questions/38552125/… "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." - ʰᵈˑ
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
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

1 Answers

0
votes

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.