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 (freeloader+myaddy@gmail.com). 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 myaddy@gmail.comInstead of "+" he used a space character. Any way to fix this?thanks in advance Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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." Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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.