Question

$url = get_url(CONFIRM,base64_encode($_POST['status']."|".$agent_id));
ta_send_verification($_POST['email'],$_POST['agent_name'],$url);

I'm sending the profile confirmation mail to user profile. That mail contains activation url link. When I click that link I got this url

Wrong url

MlJPSEU0WEFKVlNZSFZFRFVXMlk1VVpUUTBIRk1KT0w0WDVBUzNVMnwyNA==

Correct url

MlJPSEU0WEFKVlNZSFZFRFVXMlk1VVpUUTBIRk1KT0w0WDVBUzNVMnwyNA

Second url is the correct one and it works fine too. But, In my activation link I always get the url with this == equal to symbol. I don't know how can I remove that == equal to symbol in my activation url link?

Was it helpful?

Solution

That's a default behaviour of the base64_encode() as == is nothing but padding.

From the wikipedia of base64 encoding..

The '==' and '=' sequence indicate that the last group contained only 8 or 16 bits, respectively.

To remove that, simple do a str_replace() for the double equal symbol.

$url = get_url(CONFIRM,base64_encode($_POST['status']."|".$agent_id));
$url = str_replace('==','',$url);

OTHER TIPS

This answer is old, but it would be a bit safer to do a trim() because then we know we're just removing stuff at the start/end.

example:

function getCleanBase64(string $my_string): string {
    return trim(base64_encode($my_string), '=');
}

echo getCleanBase64('test');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top