-
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
-
Hi,
the script should do mimimal urlencoding of data: change % into %25 and & into %26
Musicman
-
im not sure i understand what you mean musicman.
change % where?
james
-
Hi,
add something to your script that changes data, like
$text =~ s/%/%25/g;
$text =~ s/&/%26/g;
before it writes them
Musicman
-
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;
}
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|