Mixedfruitjuice Mixedfruitjuice - 1 year ago 79
PHP Question

Keep the + in a get request string

I'm working on a website for parkos where clients can make reservations with there email but some clients use a plus sign in their email.

for example:


Now if for example clients wanted to see their reservations I'm creating a get request in the url and you would get something like this:


after that I'm trying to retrieve the email and echo it:

$email = request()->input('email');
{{!! $email!!}}

Than If I try to view on it my webpage this is what I get:

test parkos@gmail.com

The + sign is gone and I was wondering if there is a way to keep the + sign.

Answer Source

Url is wrong because + sign has its own meaning according to CGI standard. It means a whitespace.

Right url shold be


As explained in URLs and plus signs

+ becomes %2B
space becomes %20

In order to avoid further mistakes, best practice is encoding text before using it in a URL like this:

$url = "http://" . $domain . "/whatever.php?text=" . urlencode($text);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download