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
Solved

Check to see if the submit button was pushed using PERL

Posted on 2004-10-03
6
308 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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 …

860 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