View Full Version : redirect to Previous Page

08-27-2009, 08:26 AM
Hello Every 1

This Code Redirect the User after post message to the Index page of my site , I need to edit it where it redirect him to the previous page from where he sent the message .

if ( empty($_POST["name"])) {
redirect_header(site_URL . "/index.php" , 3, _MD_MSGNAMEINS);
} else if (mb_strlen($_POST["name"]) > $b) {
redirect_header(site_URL . "/index.php" , 3, _MD_MSGENAMEINS_LONG);

2- from the Code as u can see that mb_strlen been used , as some Servers disabled it by Defualt , Is it Ok if just i use strlen

08-27-2009, 08:29 AM
That depends on if you're planning on supporting multi-byte charsets or not. If you're not, than go ahead and change it to just strlen.

Referrer is provided by the $_SERVER['HTTP_REFERER'] and may or may not be set:

$sReferPage = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : site_URL . '/index.php';

That should work, use $sReferPage instead of hard-coded location.

08-27-2009, 09:09 AM
Thank you , ..

if you're planning on supporting multi-byte charsets or not

Yes i do want Multi-byte but with strlen , i did not have any problem with Charsets , All Comment pass as is when Entered..

08-27-2009, 10:27 AM
mb_strlen is used to determine the number of characters in a particular string, normally in multibyte languages.
In other words, if you're constricting to a maximum number of $b on a multibyte input, they will only be allowed to use 0.5*$b characters using unicode for example if you choose to use strlen instead of mb_strlen.
strlen on the other hand also returns the number of chars in a string, but it is restricted to 1 byte chars (I assume its still this way, though PHP6 will be changing it).
So, if you want to support a multibyte charset without using an mb_strlen, you can instead multiply the size of $b by the number of bytes in a char. That should get you the correct count to restrict against.

08-27-2009, 09:12 PM
Thx for clear things Up for me ..

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum