A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: dynamic "&" sign?

  1. #1
    Member
    Join Date
    Sep 2000
    Location
    porto
    Posts
    74

    dynamic "&" sign?

    im using a cgi script to modify a txt file and thus alllow a client to update text on his site.
    the probelm is that whenever you input the "&" sign in the content the script has problems due to the way the txt arranged the variables. ie var1=var1&var2=var2

    is there any way around this problem other than telling my client never to use the "&" sign

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    the script should do mimimal urlencoding of data: change % into %25 and & into %26

    Musicman

  3. #3
    Member
    Join Date
    Sep 2000
    Location
    porto
    Posts
    74
    im not sure i understand what you mean musicman.
    change % where?

    james

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    add something to your script that changes data, like
    $text =~ s/%/%25/g;
    $text =~ s/&/%26/g;
    before it writes them

    Musicman

  5. #5
    Member
    Join Date
    Sep 2000
    Location
    porto
    Posts
    74
    ah!
    so do i need to put that code on each variable?

    heres my script

    cheers for your help

    james

    #!/usr/bin/perl
    # use strict;

    require "subparseform.lib";
    &Parse_Form;

    $aboutus = $formdata{'aboutus'};
    $sales = $formdata{'sales'};
    $watercolour = $formdata{'watercolour'};
    $workdrgs = $formdata{'workdrgs'};
    $vis = $formdata{'vis'};
    $desplan = $formdata{'desplan'};
    $contact = $formdata{'contact'};
    $mail = $formdata{'mail'};
    $update = $formdata{'update'};
    $imsales = $formdata{'imsales'};
    $imwatercolour = $formdata{'imwatercolour'};
    $imworkdrgs = $formdata{'imworkdrgs'};
    $imvis = $formdata{'imvis'};
    $imdesplan = $formdata{'imdesplan'};

    @New = ("aboutus=$aboutus&sales=$sales&watercolour=$water colour&workdrgs=$workdrgs&vis=$vis&desplan=$despla n&contact=$contact&mail=$mail&update=$update&imsal es=$imsales&imwatercolour=$imwatercolour&imworkdrg s=$imworkdrgs&imvis=$imvis&imdesplan=$imdesplan");

    open (LOG, ">../Ex2TextFile.txt") || &ErrorMessage;
    print LOG "@New";
    close (LOG);


    print "Content-type: text/html\n\n";
    print "Status=Success - All web site content has been updated ";

    sub ErrorMessage {
    print "Content-type: text/html\n\n";
    print "Status=Connection Failed Please Check the path to the text File";
    exit;
    }

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi

    this should also work
    foreach $key (keys %formdata)
    { $formdata{$key} =~ s/%/%25/g;
    $formdata{$key} =~ s/&/%26/g;
    }

    Musicman

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center