Jump to content

PHP GET doesn't include "+" from URL

Go to solution Solved by Tycho,

Oops sorry, not %20, I meant %2B

Doesn't matter, since + is the only special character that can occur in this string i just did this 

$key = str_replace(" ","+",$key);

Thanks for your help anyway

Hey people, I've got a bit of a weird here, just as the title implies.

 

this Is the URL, notice the + as third last character

http://localhost:8080/activate.php/?user=Tycho&key=HBFoRjKP413osr/5HJySJLmRaXPyVYLh5EnbVjGhz+M=

 

this is the code 

<?phprequire_once $_SERVER['DOCUMENT_ROOT'] . '/config/db.php';$conn = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die('Can not connect to database');$message = "";if((isset($_GET['user']))&&(isset($_GET['key']))){    $user = $_GET['user'];    $key = $_GET['key'];    try{        $sql = "SELECT user_name, user_activation_key, user_status FROM users WHERE user_name ='".$user."'";        $username1 = $conn->query($sql);        $username = $username1->fetch_object()->user_name;        $activationkey1 = $conn->query($sql);        $activationkey = $activationkey1->fetch_object()->user_activation_key;        $userstatus1 = $conn->query($sql);        $userstatus = $userstatus1->fetch_object()->user_status;        echo $key;        echo "<br>";        echo $activationkey;        if(($user == $username)){            if($key == $activationkey){                if($userstatus == "1"){                    $sql="UPDATE users SET user_status=2 WHERE user_name ='".$username."'";                    $conn->query($sql) or die("Can not update");                    $message = "Your account has been activated succesfully!";                }            }        }else{            $message = "This account has already been activated.";        }    } catch(Exception $e){        $message = "This user is not registered.";    }}else{    $message = "invalid request.";}echo $message;

This is the output

HBFoRjKP413osr/5HJySJLmRaXPyVYLh5EnbVjGhz M=HBFoRjKP413osr/5HJySJLmRaXPyVYLh5EnbVjGhz+M=

As you can see everything works except that +...

 

Any ideas on this?

 

 

CPU: Intel Core i5 4690K @ 4.6Ghz CPU Cooler: Noctua NH-D15 GPU: GTX 1070 TI RAM: Crucial Ballistix Tactical 16GB (4x4) Mobo: ASUS Z97-PRO(Wi-Fi ac) PSU: Corsair RM Series RM750 Case: Fractal Design Define R4 no window

Link to comment
https://linustechtips.com/topic/368341-php-get-doesnt-include-from-url/
Share on other sites

Link to post
Share on other sites

+ gets replaced with a [space] in url encoding, use %20 instead

Where exactly do i put this "%20"

I tried this and it's still a space

http://localhost:8080/activate.php/?user=Tycho&key=HBFoRjKP413osr/5HJySJLmRaXPyVYLh5EnbVjGhz%20M=

CPU: Intel Core i5 4690K @ 4.6Ghz CPU Cooler: Noctua NH-D15 GPU: GTX 1070 TI RAM: Crucial Ballistix Tactical 16GB (4x4) Mobo: ASUS Z97-PRO(Wi-Fi ac) PSU: Corsair RM Series RM750 Case: Fractal Design Define R4 no window

Link to post
Share on other sites

Where exactly do i put this "%20"

I tried this and it's still a space

http://localhost:8080/activate.php/?user=Tycho&key=HBFoRjKP413osr/5HJySJLmRaXPyVYLh5EnbVjGhz%20M=
Oops sorry, not %20, I meant %2B

"My game vs my brains, who gets more fatal errors?" ~ Camper125Lv, GMC Jam #15

Link to post
Share on other sites

Oops sorry, not %20, I meant %2B

Doesn't matter, since + is the only special character that can occur in this string i just did this 

$key = str_replace(" ","+",$key);

Thanks for your help anyway

CPU: Intel Core i5 4690K @ 4.6Ghz CPU Cooler: Noctua NH-D15 GPU: GTX 1070 TI RAM: Crucial Ballistix Tactical 16GB (4x4) Mobo: ASUS Z97-PRO(Wi-Fi ac) PSU: Corsair RM Series RM750 Case: Fractal Design Define R4 no window

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×