Can anyone help, please?
(The excellent solution on here for using an external SMS service does not "fit" )

My objective is to send an SMS "receipt" from an Agent's mobile (viewing our web page) instantly to the "payer" to acknowledge receipt of a (small) cash payment .... using the bundled SMS package wih the Agent's phone contarct ... not an external SMS service.

I'm hoping to do this from our website (which the Agent will be viewing at the time of transaction) rather than a dedicated App, if possible.

I have searched everywhere for a simple solution to this and successfully used the following as a prelimanry test

<p><a href="sms:77777777777?body=SMARTiPAY. £5 received, thank you. ">Send SMS welcome message to new member ></a></p>

.. but what I actually need now is a means of replacing both the "number" and "content" with variables generated from a form on the page .... input fields "mobilenum" and "message" (or other variables if spec needs to be different?)

This is the first time I have used a forum, so I hope I'm not abusing any etiquette or people's kindness.

Thank you

Member Avatar for LastMitch

@kc.smith.100

This is the first time I have used a forum, so I hope I'm not abusing any etiquette or people's kindness.

.. but what I actually need now is a means of replacing both the "number" and "content" with variables generated from a form on the page .... input fields "mobilenum" and "message" (or other variables if spec needs to be different?)

This question is more suited in the Mobile Development section rather than PHP section! If you hava a PHP code than it's fine but if you don't my advice is to post it in the Mobile Development section

Regarding about your issue you need a API and a simple form. I think it's best that you post it in the Mobile Development section so someone can help you there instead of here.

Member Avatar for Zagga

Hi,

So you have the message sending part sorted out, you just need to change the number and the message?

<?php
if (isset($_POST['mobilenum']) && isset($_POST['message'])){
    echo "<p><a href='sms:" . $_POST['mobilenum'] . "?body=" . $_POST['message'] . "'>Send SMS welcome message to new member</a></p>";
}
?>

This will check to see if the 2 form fields exist in the POST array (assuming your form is using the POST method). If both are set it will display the customised link. Don't forget to sanitize the POST variables before you use them.

Hi Zagga, thanks so much for coming to my rescue so quickly!

I tried adding your code to a previous attempt .... but something else must be wrong in my form construction ... would you mind taking a look please?

    <!DOCTYPE html>  
     <head>  
       <meta charset="utf-8" />  
      </head>  
      <body>  
       <div id="container">  
        <h1>Sending SMS with PHP</h1>  
        <form action="" method="post">  
         <ul>  
          <li>  
           <label for="mobilenum">Mobile Number</label>  
           <input type="text" name="mobilenum" id="mobilenum" /></li>  
          <li>  
           <label for="message">Message</label>  
           <textarea name="message" id="message" cols="45" rows="15"></textarea>  
          </li>  
         <li><input type="submit" name="sendMessage" id="sendMessage" value="Send Message" /></li>  
       </form> 

then your code .. sorry, I'm getting error message when trying to post)

On my Android (4.1) link DOES open SMS screen but with empty recipient and message fields. I hope, oeverall, this is not some restriction of Android OS that I'm troubling you with.

Is there some way under the rules to thank you properly for your help?

Member Avatar for Zagga

Hi again,

The following code works on my phone (ICS I think). It's your code and mine combined a little better. Can I just check that you are saving the file as a PHP file, not a HTML file?

<?php
if (isset($_POST['mobilenum']) && isset($_POST['message'])){
    echo "<p><a href='sms:" . $_POST['mobilenum'] . "?body=" . $_POST['message'] . "'>Send SMS welcome message to new member</a></p>";
} else {
?>
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="container">
<h1>Sending SMS with PHP</h1>
<form action="" method="post">
<ul>
<li>
<label for="mobilenum">Mobile Number</label>
<input type="text" name="mobilenum" id="mobilenum" /></li>
<li>
<label for="message">Message</label>
<textarea name="message" id="message" cols="45" rows="15"></textarea>
</li>
<li><input type="submit" name="sendMessage" id="sendMessage" value="Send Message" /></li>
</form>
<?php } ?>

Zagga, thank you!!
You are an absolute b++++y marvel!
Not having any coding skills, but needing to get as close as possible to a working demo, I have trawled the web with every conceivable combination of words to find a solution, wasted hours reading pages & code .... tried scores of code bits ... and you've cracked it in no time!

Thanks so much! It seems to be against the rules, but is there some way I can at least send you a small reward? (My welcome from daniweb today says I can't post contact details?)

Marvellous!

ps .... Zagga .... are you good at PHP/MySQL too? (Just have a little thing to sort out with that .... but I really would like to pay something if there's a permitted way)

Member Avatar for Zagga

Hi again,

No reward is needed. As sickening as it sounds, helping people out is actually quite rewarding in itself :)

commented: Well said. I'll reward you for your hard work! =) +5
commented: haha, me too! +4

Zagga, that's extremely kind ...

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.