SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Form Char Limit

    I have a post form for a submission i have limited it to 160 characters

    how would i ensure when the submit.php gets the post information that it's limited to 160 characters

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2013
    Posts
    26
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    in javascript you can check using string.length and in php you can check using strlen($string)

  3. #3
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the fix i have used but it shows an error from another post form field so gotta suppress that some how
    PHP Code:
    $count mb_strlen($message);


    if (
    $count<"161")
      {
      
    // Continue if 160 Chars
      
    }
    else
      {
      echo 
    "<br>Failed...Nice Try Butt Munch";
      exit();
      } 

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2013
    Posts
    26
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    remove double quotes of 161, its numeric value

    Code:
    $count = mb_strlen($message);
    
    
    if ($count < 161)
    {
            // Continue if 160 Chars
    }
    else
    {
           echo "<br>Failed...Nice Try Butt Munch";
           exit();
    }

  5. #5
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much for that

    when i use tampa data to try and set the post value for something over the 160chars i am getting

    Code:
    Notice: Undefined index: sender in /var/zpanel/hostdata/zadmin/public_html/yoursite/login/submitphp on line 28
    Failed...Nice Try Butt Munch
    anyway i can suppress the error there?

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Show us the code.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  7. #7
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    //initilize PHP
    if ( isset ( $_POST['newsms'] ) ) //If submit is hit
    {

    // Grab the post fields
    $to $_POST['to'];
    $message $_POST['message'];
    $from $_POST['sender'];
    $id $_POST['id'];
    $user $_POST['user'];



    $count mb_strlen($message);
    if (
    $count 161)
    {
            
    // Continue if 160 Chars
    }
    else
    {
           echo 
    "<br>Failed...Nice Try Butt Munch";
           exit();

    when i submit normally when it's correct the sender post information is fine and works it's only when using tamper data it messess up

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    $_POST['sender']; doesn't exist. Do you have the name of the form field correct?
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  9. #9
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    further down the script

    $sender is called

    PHP Code:
    $sender urlencode ($from); 
    so when some one submits the sender on the main page that is then captured as $from and then urlencoded and the variable then becomes $sender.

    the weird thing is that the script works perfectly its only this if statement at the top that fails when i submit over 160 chars

  10. #10
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Wrong variable. Your $_POST['sender'] which is being placed in $from does not exist. That is what the notice means. So your "$from" variable is empty.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Bookmarks

Posting Permissions

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