[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Check to see if the submit button was pushed using PERL

Posted on 2004-10-03
6
Medium Priority
?
313 Views
Last Modified: 2013-12-25
I'm a newbie when it comes to Perl so bear with me.  There's a page I have with a form and when the person submits it it'll call itself to check if all fields were entered then go to another page if all were.  But I can't figure out what the function or method is to check if the submit button was pushed.  Any help would be appreciated.

Thanks.  
0
Comment
Question by:kevin_ma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Expert Comment

by:xDamox
ID: 12212572
Hi,

you should make the form pass all the fields to your script then go though them checking
then if theres an error display the error message else send the email
0
 
LVL 15

Assisted Solution

by:nicholassolutions
nicholassolutions earned 400 total points
ID: 12212934
You probably have a line like this in your HTML form code, correct?

<INPUT TYPE=SUBMIT NAME="buttonname" VALUE="Button Label" >

This is just like the other values in your form -- it passes the script a variable $buttonname = "Button Label";

So, to check if the submit button was pressed just use this:

if ($buttonname eq "Button Label"){
   #do something
}


0
 

Author Comment

by:kevin_ma
ID: 12213032
I tried that already, it doesn't work.   For example in ASP you have the request.form which you can use to refer to it, but in PERL I'm not sure what it is.  Anyways I found another way around it...
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
LVL 84

Accepted Solution

by:
ozo earned 1600 total points
ID: 12213170
use CGI qw/:standard/;
if( param("buttonname") eq "Button Label" ){
}
0
 
LVL 15

Expert Comment

by:nicholassolutions
ID: 12213175
Thanks ozo -- I guess I assumed he'd do

$buttonname = param("buttonname");

sorry I left that out in my code above.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 12213357
Your description is a little unclear.

Do you want to check for the fields being entered *before* the form is submitted or after?

If before, then you need to use Javascript for the validation.  If after, then just check each field name for existence, eg:

use CGI ':standard';

Empty("Field1 is empty") unless param("field1");
Empty("Field2 is empty") unless param("field2");

sub Empty {
  my $msg = shift;
  print header, $msg;
  exit;
}

Adjust the field names to whatever you have in your form.

It may help if you show us the relevant HTML section of your form.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question