PDA

View Full Version : Need help with...


Matthew Smith
02-04-2000, 05:52 PM
Hello.[nbsp][nbsp]I am almost finished with my first business site.[nbsp][nbsp]This site will sell art work of a local artist.[nbsp][nbsp]Many of the items are unique, and I need a script to change the status of the item once ordered.
[nbsp][nbsp]The ordering will be done through an email "submit" button, sending billing info from the fields as an email so that the order can be processed.[nbsp][nbsp]Once the customer hits the submit button, I would ALSO like the script to change the link on the main page to reflect that the item has been ordered.
[nbsp][nbsp]The script must:
1.[nbsp][nbsp]change the source for the thumbnail of the image to a different one(ie item1.gif changes to item1sold.gif).
2.[nbsp][nbsp]change the link on the main inventory page FROM the order form link INTO a link to a page that will state "this item has been ordered and is on hold, if you would like to special order a similiar item, contact us... etc."
[nbsp][nbsp](ie <a href=&quot;item1ORDER.htm&quot;> changes to <a href=&quot;item1SOLD.htm>
[nbsp][nbsp]All of these changes would affect only one page.[nbsp][nbsp]Any ideas?[nbsp][nbsp]I havn't messed with ASP's yet(I don't even know if they would do that).[nbsp][nbsp]I don't know MUCH CGI, but I'm learning.
[nbsp][nbsp]Is there any way to do this, or could someone recommend a FREE shopping cart that would do this or something similiar?
[nbsp][nbsp]THANKS IN ADVANCE EVERYONE![nbsp]

Rich
02-09-2000, 02:13 PM
Matthew:

What you are asking about can be done, but I do not believe you will find a commercial shopping cart application (free or otherwise) that will do this without custom design modification. Most applications like the one you described, which would be used in a very small niche market, are usually custom designed.

Rich

Griff
02-12-2000, 12:30 AM
There needs to be a whole lot more to this, but this is the basics of how this would be done in perl. You'd need to do some severe error-checking, output something to the browser and a whole bunch'o other stuff.

This has not in anyway shape or form been tested -- just hacked together from memory, stuff on the WWW and
man pages.

#!/usr/bin/perl -w

use strict ;
use CGI ;
use Fcntl ':flock';

$cgi_form = new CGI::Form;

#process form data

$from[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] = quotemeta $cgi_form->param('from');
$name[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] = quotemeta $cgi_form->param('name');
$to[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] = quotemeta $cgi_form->param('to');
$subject[nbsp][nbsp][nbsp][nbsp]= quotemeta $cgi_form->param('subject');
$message[nbsp][nbsp][nbsp][nbsp]= quotemeta $cgi_form->param('message');
$item_name[nbsp][nbsp]= quotemeta $cgi_form->param('item_name');

#substitue ORDER for SOLD

# this next section could be replaced with a simple call to
# /usr/bin/perl -i .bak -e 's/ORDER\.html/SOLD\.html/g'
# or to sed I suppose ...

open(HTML, &quot;+</path/to/html/file.html&quot;) || die ;
flock(HTML, LOCK_EX);
@a=<HTML>;
@a =~ s/ORDER\.html/SOLD\.html/g;
seek(HTML,0,0);
print HTML @a;
flock(HTML,LOCK_UN);
close HTML;

# then send out the email ...

open (SENDMAIL, &quot;| /usr/bin/sendmail -t -n&quot;);
print SENDMAIL <<End_of_Mail;
From: $from <$name>
To: $to
Reply-To: $from
Subject: $subject

$message
End_of_Mail

Hope this helps... or maybe it doesn't...

<!-- NO_AUTO_LINK -->