gnetuk Posted April 23, 2012 Share Posted April 23, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/ Share on other sites More sharing options...
Adam Posted April 23, 2012 Share Posted April 23, 2012 You may want to run the message through urlencode, but failing that it's something to raise with 'sms fun'. Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339896 Share on other sites More sharing options...
gnetuk Posted April 23, 2012 Author Share Posted April 23, 2012 Adam thanks for your responce. But i am no coder. How culd i run this through urlencode(), what would i need to ad to my existing code to achive this? Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339898 Share on other sites More sharing options...
Adam Posted April 23, 2012 Share Posted April 23, 2012 Before the curl_init() call, add: $emsg = urlencode($emsg); Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339899 Share on other sites More sharing options...
gnetuk Posted April 23, 2012 Author Share Posted April 23, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339902 Share on other sites More sharing options...
MMDE Posted April 23, 2012 Share Posted April 23, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339907 Share on other sites More sharing options...
gnetuk Posted April 23, 2012 Author Share Posted April 23, 2012 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.............. Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339918 Share on other sites More sharing options...
TOA Posted April 23, 2012 Share Posted April 23, 2012 Try the opposite: urldecode Or store the encoded version in a different variable and use the original to display back the message Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339920 Share on other sites More sharing options...
gnetuk Posted April 23, 2012 Author Share Posted April 23, 2012 Sorry for noobness waht do you mean from opposite? can i has code? Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339931 Share on other sites More sharing options...
Adam Posted April 23, 2012 Share Posted April 23, 2012 Have you read the documentation? What have you tried so far? We appreciate you're new to this, but the manual has a lot of examples. Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339936 Share on other sites More sharing options...
TOA Posted April 23, 2012 Share Posted April 23, 2012 Use it the same way you would urlencode() // for use in your message $emsg = urlencode($emsg); // for use in echoing $emsg = urldecode($emsg); echo $emsg; But Adam's right, you should be trying things for yourself and reading the manual. Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339942 Share on other sites More sharing options...
gnetuk Posted April 23, 2012 Author Share Posted April 23, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/261493-curl-spaces-errror/#findComment-1339948 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.