SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How do you adjust this for another value please?

    Hi all, Happy Easter and isn't it great to have a brilliant excuse to eat all those chocs!! Anyways, can anyone help on this? Have been trying for a few weeks to get this right, need to do it so that it's a pre-requisite to do 100 posts to post an email address and 50 posts to post a website address.
    Code:
    if ($submit || $preview || $refresh)
    {
    
        if ($user->data['user_posts'] < 100)
           {
              if (preg_match('/(http|www|dotcom|dotcodotuk)/i', request_var('message', '', true)))
              {
                 $error[] = $user->lang['NO_URLS'];
              }
          	 if (preg_match('/(@)/i', request_var('message', '', true)))
          	  {
                 $error[] = $user->lang['NO_EMAILS'];
              }
    
           
           }

  2. #2
    SitePoint Addict Kokos's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($submit || $preview || $refresh)
        if (
    $user->data['user_posts'] < 100){

              if (
    preg_match('/(http|www|dotcom|dotcodotuk)/i'request_var('message'''true)))
                 
    $error[] = $user->lang['NO_URLS'];

              if(
    $user->data['user_posts'] < 50)
                  if (
    preg_match('/(@)/i'request_var('message'''true)))
                      
    $error[] = $user->lang['NO_EMAILS'];
           
           } 
    I believe this is what you mean?

    Also, your regex are a bit off, I would suggest looking into filter_var

    Taking over the web one pixel at a time.
    Currently working @ CodeCreators

  3. #3
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Kokos, although, just tried it and got: Parse error: syntax error, unexpected '}'

  4. #4
    SitePoint Addict Kokos's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using shorthands there to avoid excess brackets, this piece of code alone shouldn't give that error but combined with your own code it could (if there is a '}' left from your previous code that shouldn't be there).

    Here is the same code without shorthands:

    PHP Code:
    if ($submit || $preview || $refresh){

        if (
    $user->data['user_posts'] < 100){

              if (
    preg_match('/(http|www|dotcom|dotcodotuk)/i'request_var('message'''true))){

                 
    $error[] = $user->lang['NO_URLS'];

              }

              if(
    $user->data['user_posts'] < 50){

                  if (
    preg_match('/(@)/i'request_var('message'''true))){

                      
    $error[] = $user->lang['NO_EMAILS'];
              
                  }

              }  
           
           } 



    Taking over the web one pixel at a time.
    Currently working @ CodeCreators

  5. #5
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Many thanks - much appreciated - all solved


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
  •