my $query = new CGI;
print $query->header;
local $ob = Session->new();
$ob->open_session(0);
# extract name and password from session
my $user = $ob->{user};
my $password = $ob->{password};
print "The user name is $user";
print "The password name is $password";
sub display_form
{
my $error_message = shift;
my $your_task = shift;
my $your_weeks = shift;
my $your_days = shift;
my $approved = shift;
my $formMonth = shift;
my $formDay = shift;
my $formYear = shift;
my $successMeasuredBy = shift;
# Build "selected" HTML for the "Approved" drop-down list
my $approved_detail = "";
my @approved_opts = ("IVM-1136","WAG");
foreach my $approved_option ( @approved_opts )
{
$approved_detail .= "<option value= \"$approved_option\"";
$approved_detail .= "selected" if ( $approved_option eq $approved );
$approved_detail .= ">$approved_option</option>";
}
print "<form action=\"addTask.cgi\" method=\"post\"> <input type=\"hidden\" name=\"submit\" value=\"Submit\"><input type=\"hidden\" name=\"user\" value=\"$user\"><input type=\"hidden\" name=\"password\" value=\"$password\"><p>$error_message</p><table>";
# [More form fields printed here]
print "<input type=\"submit\" name=\"submit\" value=\"Submit\">";
print "</form>";
print "</body></html>";
}
sub validate_form
{
print "The user is $user";
print "The password is $password";
#general variables associated with form
my $your_task = $query->param("task");
my $your_weeks = $query->param("weeks");
my $your_days = $query->param("days");
my $approved = $query->param("approved");
my $formMonth = $query->param("formMonth");
my $formDay = $query->param("formDay");
my $formYear = $query->param("formYear");
my $successMeasuredBy = $query->param("successMeasuredBy");
my $error_message = "";
$error_message .= "Please enter your task<br>" if (!$your_task);
if ( $error_message )
{
# Errors with the form - redisplay it and return failure
display_form ($error_message,$your_task,$your_weeks,$your_days,$approved,$formMonth,$formDay,$formYear,$successMeasuredBy);
return 0;
}
else
{
return 1;
}
}
sub process_form
{
if ( validate_form ( ) )
{
# update database and print thank you message
}
}
# Process form if submitted; otherwise display it
if ( $query->param("submit") )
{
process_form ( );
}
else
{
display_form ();
}
$ob->close_session();
[edited by: sugarkane at 5:58 pm (utc) on Nov. 4, 2003]
[edit reason] Removed some code for readability [/edit]
I have to admit I've not used the Session module, but I notice that you're manually printing the <form action=""> tag. As far as I can see, the session module relies on using the start_form() method to construct that tag and pass the session id around - could this be your problem?