MySQL Forums
Forum List  »  Perl

Re: Its working now...!!!
Posted by: Nick Roper
Date: May 02, 2005 04:08AM

Hi Naveen,

OK, as you asked so nicely ;-)

First of all, whether or not to create functions in the same pl script, or in a separate script ? My tendency would be to create them in a separate script and then include this into your main script. In this way you can use the functions in any other script that you create, and you only have to edit a single file if you want to change the functions in any way. If the functions are very specific to this script, and will never be used elsewhere, then create them in the main script.

Next - the form methods. I would always recommend using the POST method for forms, as it helps with security and doesn't expose the name/value parameters via the URL. So, make the form's method=POST and then create your two buttons. Give each button the same name ('submit') but different values, e.g.

<input type="submit" name="submit" value="View Profile">
<input type="submit" name="submit" value="Update Profile">

then, you can check to see which button was used as follows:

#######################################

# get the form data
@params = $query->param();

#What are we doing?

$action=$query->param("submit");

if ($action eq "View Profile") {

# do view stuff here... ;

} elsif ($action eq "Update Profile") {

# do update stuff here... ;

} else {

# no button clicked - so initialise the page ;

}

rest of code here ;

#######################################


Is this the kind of thing you need ?

Cheers,

Nick

--
Nick Roper

Options: ReplyQuote


Subject
Written By
Posted
May 02, 2005 01:16AM
May 02, 2005 02:19AM
Re: Its working now...!!!
May 02, 2005 04:08AM
May 02, 2005 06:08AM
May 02, 2005 06:19AM
May 02, 2005 06:36AM
May 02, 2005 07:25AM
May 02, 2005 11:49PM
May 03, 2005 03:58PM
May 04, 2005 04:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.