Alexmjw222
Technical User
I am having a small issue I have a script that takes form data the enters it in to a XML page to be used later but as the script runs it enters spaces before the pervious entry if any one could help that would be great. BTW I am trying to keep it somewhat simple.
============================================================
#!/usr/bin/perl
use CGI ':standard';
"Content-type: text/html\n\n";
$database="items.xml";
$loc=param('loc');
$categories=param('categories');
$item=param('item');
$itemdes=param('itemdes');
$price=param('price');
$unit=param('unit');
$quantity=param('quantity');
$numcat="9";
if ($categories eq giving_works) {
$numcat="0";
}elsif ($categories eq tools_parts){
$numcat="1";
}elsif ($categories eq antiques){
$numcat="2";
}elsif ($categories eq vechicles){
$numcat="3";
}elsif ($categories eq toys_hobbies){
$numcat="4";
}elsif ($categories eq dishware_pottery){
$numcat="5";
}elsif ($categories eq appliances){
$numcat="6";
}elsif ($categories eq furniture){
$numcat="7";
}elsif ($categories eq jewlery){
$numcat="8";
}elsif ($categories eq other){
$numcat="9";
}
open(DATABASE, "<$database");
@lines=<DATABASE>;
pop(@lines);
close(DATABASE);
open(DATABASE, ">$database");
print(DATABASE "");
close(DATABASE);
open(DATABASE, ">>$database");
print(DATABASE "@lines
<$categories>
<item>$loc$numcat$item</item>
<itemdes>$itemdes</itemdes>
<price>$price</price>
<unit>$unit</unit>
<quantity>$quantity</quantity>
</$categories>
</item>");
close(DATABASE);
exit();
============================================================
#!/usr/bin/perl
use CGI ':standard';
"Content-type: text/html\n\n";
$database="items.xml";
$loc=param('loc');
$categories=param('categories');
$item=param('item');
$itemdes=param('itemdes');
$price=param('price');
$unit=param('unit');
$quantity=param('quantity');
$numcat="9";
if ($categories eq giving_works) {
$numcat="0";
}elsif ($categories eq tools_parts){
$numcat="1";
}elsif ($categories eq antiques){
$numcat="2";
}elsif ($categories eq vechicles){
$numcat="3";
}elsif ($categories eq toys_hobbies){
$numcat="4";
}elsif ($categories eq dishware_pottery){
$numcat="5";
}elsif ($categories eq appliances){
$numcat="6";
}elsif ($categories eq furniture){
$numcat="7";
}elsif ($categories eq jewlery){
$numcat="8";
}elsif ($categories eq other){
$numcat="9";
}
open(DATABASE, "<$database");
@lines=<DATABASE>;
pop(@lines);
close(DATABASE);
open(DATABASE, ">$database");
print(DATABASE "");
close(DATABASE);
open(DATABASE, ">>$database");
print(DATABASE "@lines
<$categories>
<item>$loc$numcat$item</item>
<itemdes>$itemdes</itemdes>
<price>$price</price>
<unit>$unit</unit>
<quantity>$quantity</quantity>
</$categories>
</item>");
close(DATABASE);
exit();