Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to echo javascript encoded url from GET variable on php

Tags:

php

How to echo-ing decoded url from GET method on php,

i have this link:

localhost/whatsapp?text=Hello%2C%20Who%20are%20U%3F%0AName%3A%20%0AAddress%3A%20%0AAge%3A%20

with this code

$text = $_GET['text'];
header("Location: https://web.whatsapp.com/send?phone=00000000&text=".$text);

but get error

Warning: Header may not contain more than a single header, new line detected in index.php on line

like image 445
Great Saiyaman Avatar asked Jun 04 '26 18:06

Great Saiyaman


1 Answers

When you retrieve values from $_GET, they are URL decoded. If you want to pass it back, you need to encode it again, so that newlines, spaces and other weird characters gets encoded. Use urlencode($text) for this.

$text = $_GET['text'];
header("Location: https://web.whatsapp.com/send?phone=00000000&text=".urlencode($text));
like image 178
Qirel Avatar answered Jun 07 '26 08:06

Qirel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!