A weird problem...
Ok, this is going to be along post, but I'm guessing the answer is pretty simple, so here it goes...
Please review the script which I posted below. He's my problem: when I goto 'post.cgi?showpost' the HTML page shows and everything (please tell me if the HTML is wrong), but when I submit (post) the info to 'post.cgi?savepost' it brings me to the 'showerror' part of the script, and doesn't execute the 'savepost' part. What am I doing wrong. I'm really guessing it's the HTML, but I'm not experianced enough to figure out what I'm missing. Any help is appreciated! The script follows...
code:
#!/usr/bin/perl ####################################################################### ## POST.CGI ## Justin Stayton ## Copyright (c) 2000 ####################################################################### ####################################################################### ## VARIABLES ####################################################################### $postfile = "/home/flamehos/public_html/cgi-bin/bz/1.dat"; $date = localtime; ####################################################################### ## CODE ####################################################################### ## PARSE URL DATA use CGI qw/:standard/; $action = param('action'); ## USE THE PARSED DATA AND SHOW RELEVENT INFORMATION if($action eq "showpost") { &showpost; } elsif($action eq "showreply") { &showreply; } elsif($action eq "savepost") { &savepost; } elsif($action eq "savereply") { &savereply; } else { &showerror; } ## SHOW POST PAGE sub showpost { print "Content-type: text/html\n\n"; print <<"EOT"; <html> <head> <title>Post Page</title> </head> <body bgcolor="#FFFFFF"> <form action="http://www.flamehosting.com/cgi-bin/bz/post.cgi?action=savepost" method="POST"> <p>Username:<br> <input type="text" size="20" name="username"></p> <p>Message:<br> <textarea name="message" rows="5" cols="50"></textarea></p> <p><input type="submit" value="Submit"></p> </form> </body> </html> EOT exit; } ## SHOW REPLY PAGE sub showreply { print "Content-type: text/html\n\n"; print "this is a test 2"; exit; } ## SAVE POST CODE sub savepost { use CGI; $in = new CGI; %in = ( username => $in->param(username), message => $in->param(message), ); print "Content-type: text/html\n\n"; open(POSTCODE, ">>$postfile") or die "Cannot open $newfile: $!"; print POSTCODE "$in{username}| |$date| |$in{message}\n"; close (POSTCODE); print "Post Message Saved"; exit; } ## SAVE REPLY CODE sub savereply { print "Content-type: text/html\n\n"; print "this is a test 4"; exit; } ## SHOW ERROR PAGE sub showerror { print "Content-type: text/html\n\n"; print "Sorry, there was an error processing your request"; exit; } ####################################################################### ## END OF POST.CGI ####################################################################### [/code] ------------------ Critiquing over 1000 sites on the Internet today...
Justin Stayton - [email] [icq]
Rob Pengelly posted this at 11:54 — 7th June 2000.
They have: 850 posts
Joined: Jul 1999
I think it may be
<form action="http://www.flamehosting.com/cgi-bin/bz/post.cgi?action=savepost" method="POST">
"?action=savepost". I don't think you can do this? The best thing to do you just put a
<input type="hidden" name="action" value="savepost">
------------------
click here to help save lives
http://www.wiredstart.com : The Technology Start Page
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Justin S posted this at 14:06 — 7th June 2000.
They have: 2,076 posts
Joined: Jun 1999
Well whaddya know! That works! I thought I'd tried that already, but I guess I didn't. Thanks alot Rob!
------------------
Critiquing over 1000 sites on the Internet today...
Justin Stayton - [email] [icq]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.