On Monday 18 June 2001 22:35, Vontel Girish wrote:
> I have just started to create a sample online store
> with Unix OS, Apache web server, CGI with perl and
> MySQL database.
>
> The perl program given below splits the querystring
> into Name value pairs.
>
> -----------------------------------------------
> #!/usr/local/bin/perl
> if($ENV{'REQUEST_METHOD'}eq 'GET'){
> $form_into = $ENV{'QUERY_STRING'};
> }
> else{
> $input_size = $ENV{'CONTENT_LENGTH'};
> read(STDIN,$form_info,$input_size);
> }
> @input_pairs = split(/[&;]/,$form_info);
> %input=();
> foreach $pair(@input_pairs){
> $pair=~ s/\+/ /g;
> ($name, $value)=split(/=/,$pair);
> $name =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
> $value=~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
> $input{$name}=$value;
> }
> ---------------------------------------
>
>
> CAN ANYONE TELL ME WHEN I AM WRITING  A CGI PROGRAM
> FOR CONNECTING TO MYSQL DATABASE AND DUMPING THE DATA
> INTO THE TABLE, WILL I HAVE TO INCLUDE THE ABOVE PIECE
> OF CODE FOR SPLITTING THE QUERYSTRING INTO NAME VALUE
> PAIRS?????
>
> THANKS.
> VONTEL  GIRISH
> THANKS
>
>
> ____________________________________________________________
> Do You Yahoo!?
> For regular News updates go to http://in.news.yahoo.com


Why not use  CGI.pm to handel splitting up the values passed by a form .

it's a lot easer

# example
use strict;
use CGI qw( :standard);

my $name = param( "name");


or

use strict;
use CGI;

my $q = new CGI;
my name = $q->param( "name");

for the OOP way of doing it.

That way you dont have to even deal with the enviroment varitables.

all you need to know is what the name of the name value pair , Perl takes 
care of extracting the "VALUE" for you . 

I work with mySql and Perl in a simular manner , I would also recomend you 
use the "DBI.pm" and MySql drivers  to access the data base , it makes it 
quite easy.

hope this helps.

Greg

Reply via email to