Jump to content

Recommended Posts

I am trying to use CURL on a site., to send SMS/TXT messages.

 

HERE IS THE CODE

 

$name = $_POST['name'];  
$emsg = $_POST['emsg']; 

           $ch = curl_init("https://www.smsfun.com.au/api/login.php?mobile=emma&password=123456&send_to=$name&message=$emsg&send=1");
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);       
        curl_close($ch);

 

Then i use my form like this

 

<form method="post" action="" value "">
  <p align="center"><strong><font color="#0000FF" size="5" face="Courier New, Courier, mono">MOBILE 
    NO<br>
    <input name="name" type="text">
    </font></strong></p>
  <p align="center"><strong><font color="#0000FF" size="5" face="Courier New, Courier, mono">message</font><font color="#0000FF" size="5" face="Courier New, Courier, mono"><br>
    <textarea name="emsg" value "$emsg" rows="5" wrap="VIRTUAL"></textarea>
    </font></strong><br>
    <input type="submit" name="submit" value="SEND">
  </p>
</form>

 

This all works fine but if the user needs to put a space after a word i.e  "hello this is a test" this wont work only "hellothisisatest" will.

 

Am i missing somtink here? I tryed googleing etc cannot find the answer.

 

Please help

 

Thanks

 

g-netUK

Link to comment
https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/
Share on other sites

you need a reward. i been on this for so long now worked first time.

 

ok but i may be picky but the echo result on my page has + for the spacebars.

 

any way of not showing the +  its like hello+i+am+your+friend.

 

dont worry about it you have just made my menelium.

Link to comment
https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339902
Share on other sites

you need a reward. i been on this for so long now worked first time.

 

ok but i may be picky but the echo result on my page has + for the spacebars.

 

any way of not showing the +  its like hello+i+am+your+friend.

 

dont worry about it you have just made my menelium.

try %20 instead of +

urlencode will do this for you with a string!

 

echo urlencode('Hello I\'m your friend.');

 

Hello+I%27m+your+friend.

Link to comment
https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339907
Share on other sites

This works fine

 

$emsg = urlencode($emsg);

 

I can use spaces and the TXT/SMS will send with the spaces. But............................

 

I have a echo output on my page to explain to the user what has happend.

 

   echo "<br>";  

    echo "<font size=\"4\" face=\"Courier New\"><div align='center'>You Has SENT a message to this phoneNO : <b> $name </b></div>";
echo "<font size=\"4\" face=\"Courier New\"><div align='center'>And entered this MESSAGE : <b> $emsg </b></div>";

    echo "<br>";  

 

but the output uses + as a space this is fine but fine tuning why cant it just use a space instaead of the +

 

im just glad i have got this far..............

Link to comment
https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339918
Share on other sites

Adam is right i can read code but cant write it......

 

 

DevilsAdvocate

 

&

 

Adam

 

 

you have made my wish come true. Dont get me wrong i will always try to find this things out for my self

 

Devils you line worked too. i can now have echo without the ++++++'s for spaces , it just drives me mad how two simple lines of code can work more wonders that the whole google reading thing.

 

 

Like i say i can read it..... just wish i could write it waell as u guys.

 

 

thanks both for the quick responce and solutions

 

<G>

Link to comment
https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339948
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.