Solved

Check to see if the submit button was pushed using PERL

Posted on 2004-10-03
6
303 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
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 100 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 84

Accepted Solution

by:
ozo earned 400 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now