Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    redirect to Previous Page

    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 .

    PHP Code:
       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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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:
    PHP Code:
    $sReferPage = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : site_URL '/index.php'
    That should work, use $sReferPage instead of hard-coded location.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    ajloun (08-27-2009)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    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..

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    ajloun (08-27-2009)

  • #5
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thx for clear things Up for me ..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •