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