#!/usr/bin/perl use strict; use XML::Smart; use CGI; use HTML::Template; use lib ('../'); use MySite; my $q = CGI->new(); my %params = MySite::get_params($q); my $add_quote_success= HTML::Template->new(filename =>'../templates/add_quote_success.tmpl'); my $add_quote_error= HTML::Template->new(filename =>'../templates/add_quote_error.tmpl'); if ($ENV{REQUEST_METHOD} ne 'POST') { print "Content-type: text/html\n\n"; print "Stop wgetting this script."; } else { if (($params{txt} eq '') or ($params{play} eq '')) { print $q->header(-charset => 'utf-8'); print $add_quote_error->output; } else { my $XML = XML::Smart->new('../xml/newfile.xml'); my $counter = @{$XML->{quotes}{txt}}; $XML->{quotes}{txt}[$counter] = "$params{txt}\n"; $XML->{quotes}{play}[$counter] = "$params{play}\n"; $XML->save('../xml/newfile.xml'); print $q->header(-charset => 'utf-8'); print $add_quote_success->output; } }