ajaxboy / cjax

Lightweight Ajax Framework built in PHP with no foot-print. Allows you to build ajax functionality with a single line of code & do so much more, right from the back-end!
http://cjax.sourceforge.net/
66 stars 27 forks source link

Plus signs (+) being suppressed #10

Closed templeman closed 10 years ago

templeman commented 10 years ago

When submitting a form with CJAX, form values containing the plus sign symbol are reaching the handler script with spaces in place of plus signs. So submitting email+1@gmail.com comes through as email 1@gmail.com.

Is there a way to preserve "+" symbols across the CJAX encoding process?

ajaxboy commented 10 years ago

Hi Templateman,

Try email[plus]1@gmail.com

or do

$ajax->encode('email+1@gmail.com');

-Cj

templeman commented 10 years ago

Thanks Ajaxboy. Here is the code I used to get it working:

$_POST['email'] = $ajax->encode($_POST['email']);
$_POST['email'] = rawurldecode($_POST['email']);

Using $ajax->encode() does bring back the missing "+" sign. However, it also encodes the special characters, so it ends up returning email+1%40gmail.com. Running the result through rawurldecode() closes the loop and brings it back to the original value, i.e. email+1@gmail.com.