SPUG: Using a Duplicate Value Error Message

Fred Morris m3047 at inwa.net
Tue Mar 20 08:53:10 PDT 2007


Hello Will, welcome to the list!

Without critiquing style (doesn't this come down to style?), isn't the answer 
obviously that what you'd normally do at that point in the code is display 
whatever congratulations page you're planning to send to the user for 
registering? You have to send something to the user as a success page if they 
are successful.

FIRST: You have to test $sth for success, that is to say
  $an_error = (! $sth);

At that point you can conditionally decide to display the success page or the 
existing error page. If you parameterize the existing error page:

sub error {
  my $message; (defined ($message = shift)) or $message = '';

then you can decide to print the message out at some point in the body of your 
error document:

<div align="center"><P>$message<P>Whoa! You just ran into an error! </div>


Putting it together:

if ($sth) {
  thankyou(); # to-do
}
else {
  error("Registration Failed!");
}

Note that you could parameterize your welcome() page the same way, and simply 
redisplay it with a message that registration failed.

Hope that helps...

--

Fred Morris
http://devil.m3047.inwa.net/contact.html

--

On Monday 19 March 2007 18:53, Will Kidwell wrote:
> [...]
> The script works, but in the "make_handle" subroutine, which inserts the
> username/passwords input to the DB, I am trying to figure out what to do if
> the proposed handles already exist.  How do I notify the user of the error
> and to try again?
> [...]


More information about the spug-list mailing list