freeloader Posted November 24, 2006 Share Posted November 24, 2006 Hi guys,I'm writing a prog that gives an email through a form to a website. I'm using gmails trick ([email protected]). I give the program the email value and have it echo it to be sure. [code]echo "$email\n";[/code]It displays it correctly.Then I give it to the website through cURL.[code]"&password=mypass&email=".$email."&password2=mypass&email2=".$email."[/code]The postfield goes on but that's the important part.Now when I check it with echo, I notice he didn't send the + sign to the server. This is what he sends as email address:freeloader [email protected]Instead of "+" he used a space character. Any way to fix this?thanks in advance Link to comment https://forums.phpfreaks.com/topic/28372-sign/ Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 You can easily use str_replace[code]$email = str_replace(" ","+",$email);[/code]which will take the space from the variable and replace it with the plus (+) sign Link to comment https://forums.phpfreaks.com/topic/28372-sign/#findComment-129766 Share on other sites More sharing options...
onlyican Posted November 24, 2006 Share Posted November 24, 2006 thats because + is not a valid symbol in URLs or EmailsTill now with gmail anyway Link to comment https://forums.phpfreaks.com/topic/28372-sign/#findComment-129768 Share on other sites More sharing options...
Barand Posted November 24, 2006 Share Posted November 24, 2006 try"&password=mypass&email=".urlencode($email)."&password2=mypass&email2=".$email." Link to comment https://forums.phpfreaks.com/topic/28372-sign/#findComment-129770 Share on other sites More sharing options...
kenrbnsn Posted November 24, 2006 Share Posted November 24, 2006 A plus sign in a URL is an alternate version of an urlencoded space.You can solve this by urlencoding the text before you pass it, so the plus sign becomes "%2B" in the URL. When the recieving script get it, this will be translated back to "+".[code]<?php"&password=mypass&email=".urlencode($email)."&password2=mypass&email2=".urlencode($email)."?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/28372-sign/#findComment-129776 Share on other sites More sharing options...
freeloader Posted November 24, 2006 Author Share Posted November 24, 2006 Brilliant :D Thanks for the help guys, the urlencoding did the trick, works like a charm.Another happy virtual costumer :p Link to comment https://forums.phpfreaks.com/topic/28372-sign/#findComment-129777 Share on other sites More sharing options...
brendandonhue Posted November 25, 2006 Share Posted November 25, 2006 urlencode() changes spaces to plus signs. Use rawurlencode() if you want spaces to become %20. Link to comment https://forums.phpfreaks.com/topic/28372-sign/#findComment-129830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.