www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: Perl syntax question

  1. #1
    Join Date
    Feb 2003
    Posts
    70

    Perl syntax question

    Anybody know what the Perl syntax would be to allow the characters "http://" to be the default value in the URL field on my form ( http://www.usedflutes.com/addpage.html ). Needs to be configured so that if someone chooses not to post a URL (field is optional), would strip the "http://" so that the field would post as empty?

    Many thanks is advance,

    -Bob

  2. #2
    Join Date
    Feb 2003
    Posts
    70
    The Perl script for the URL field to modify looks like this:

    if ( $FORM{'url'} ){
    print MAIL "$FORM{'url'} ";
    }

  3. #3
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    Code:
    delete $FORM{url} if $FORM{url} eq 'http://';
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  4. #4
    Join Date
    Feb 2003
    Posts
    70
    Thanks for trying Jeff, unfortunately the code doesn't work - 'http://' still came through...

    -Bob

  5. #5
    Join Date
    Feb 2003
    Posts
    70

  6. #6
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    Then either the value was not actually 'http://' or the code I gave was inserted to late in the program. If you consider the example:
    Code:
    $FORM{url} = 'http://';
    delete $FORM{url} if $FORM{url} eq 'http://';
    print $FORM{url};
    nothing will be printed.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  7. #7
    Join Date
    Feb 2003
    Posts
    70
    Hi Jeff,

    >Then either the value was not actually 'http://' or the code I gave was inserted to late >in the program.

    The "http://" comes from the form http://www.usedflutes.com/addpage_URL.html so I don't think that was the problem. As for placement, I did put it up towards the beginning so not sure about that either.


    >If you consider the example:


    code:
    ------------------------------------------------------------------------
    $FORM{url} = 'http://';
    delete $FORM{url} if $FORM{url} eq 'http://';
    print $FORM{url};
    ------------------------------------------------------------------------
    nothing will be printed.

    OK, I'll try this and see. What I'm really looking for however, is to have the "http://" only stripped if there's nothing added to it. If someone adds to the http:// , then I want that UEL value to go through. Any ideas how to set that up?

    Thanks Jeff,

    -Bob

  8. #8
    Join Date
    Feb 2003
    Posts
    70
    Hi Jeff,
    OK - I just tried your new code, but no luck there either sorry to say. Maybe it'd help if you saw the script that I'm using?

    http://www.scriptarchive.com/downloa...guestbook%2Epl

    Thanks Jeff,

    -Bob

  9. #9
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    bobafifi
    As for placement, I did put it up towards the beginning
    That's a very broad statement and doesn't tell me a whole lot. It has to go somewhere after the parameters are parsed and before it is printed to GUEST.

    What I'm really looking for however, is to have the "http://" only stripped if there's nothing added to it. If someone adds to the http:// , then I want that UEL value to go through. Any ideas how to set that up?
    Yeah, what I already gave you.

    OK - I just tried your new code, but no luck there either sorry to say
    The new code I gave was merely an example and not meant to be the solution.

    Maybe it'd help if you saw the script that I'm using? http://www.scriptarchive.com/downlo...=guestbook%2Epl
    The scripts available at scriptarchive.com are buggy and insecure, and should NOT be used. Even Matt no longer recommends his scripts.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  10. #10
    Join Date
    Feb 2003
    Posts
    70
    Hi Jeff,
    My apologies...
    I made the mistake of not slightly modifying your code so that it would be read right

    (needed to change {url} to {'url'} ) and it works! :-) Thanks!

    However, I've now got another problem with the code:
    I use the script to send me INSERT statements for the MySQL database that I use. Since the {'url'} field is completely deleted if your code is activated, I lose the {'url'} field value for the INSERT statement and so the MySQL insert fails:

    For example, this is formatted OK:


    INSERT INTO `MySQL` (`Title`, `Email`, `City`, `State`, `Country`, `URL`, `Date`,
    `Description`, `rid`) VALUES ('Test', 'bob', 'Seb', 'Ca', 'USA ', 'http://', 'Wednesday, February 19, 2003 ',
    'Sadasd', '')

    and this is not:

    INSERT INTO `MySQL` (`Title`, `Email`, `City`, `State`, `Country`, `URL`, `Date`,
    `Description`, `rid`) VALUES ('Test', 'bob', 'Seb', 'Ca', 'USA ', , 'Wednesday, February 19, 2003 ', 'Sadasd',
    '')


    Is it possible to delete the "http://" biz while still retaining the {'url'} value for the form?

    Thanks again Jeff,

    -Bob

  11. #11
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    bobafifi
    needed to change {url} to {'url'} ) and it works
    There must be something else that was changed because there is no difference between those two.

    Is it possible to delete the "http://" biz while still retaining the {'url'} value for the form?
    Code:
    $FORM{url} = '' if $FORM{url} eq 'http://';
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  12. #12
    Join Date
    Feb 2003
    Posts
    70
    Hi Jeff,
    <There must be something else that was changed because there is no difference between those two.

    Well yes, I did change the "eq" to "=" (eq consisitently failed to post) and provide curly braces before and after the code. Anyhow, I just installed your last code in a similar fashion which for some reason is also deleting the url completely - regardless of what text is in the url field. Not sure what's up, but that's what's happening.

    {

    $FORM{'url'} = '' if $FORM{'url'} = 'http://';

    }


    Thanks again Jeff for your help,

    -Bob

  13. #13
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    bobafifi
    Anyhow, I just installed your last code in a similar fashion which for some reason is also deleting the url completely - regardless of what text is in the url field
    That's because you changed eq to =, don't do that. The curly braces don't hurt it, but don't do anything either. If it still doesn't work then upload your modified script.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  14. #14
    Join Date
    Feb 2003
    Posts
    70
    Hi Jeff,
    OK, I can't figure it out...
    If I leave the code 'as is,' code doesn't do anything - form processes as usual.
    If I change the 'eq' to '=,' then the code works but removes the {'url'} field completely.
    So anyhwow, here's the script:

    http://usedflutes.com/guestbook_modified.txt

    Thanks again Jeff,

    -Bob

  15. #15
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    ...where's the snippet I gave you in there?
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles