Current location: Hot Scripts Forums » Programming Languages » Perl » Building a web form with Perl


Building a web form with Perl

Reply
  #1 (permalink)  
Old 03-01-11, 07:57 PM
GRichG GRichG is offline
New Member
 
Join Date: Mar 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Building a web form with Perl

Hi, I'm a new guy and I hope this question has not been answered over and over..........

I have a web page with a form that has several hidden fields. When the submit button is pressed it calls a cgi script. That script sends out a couple of emails and creates another web page with a form with some of the hidden fields from the first page. When the submit button on the second form is pressed it calls a cgi script from a comercial card processing company.

The problem comes when I build the second form. The information in some of the fields has two or more words, such as "PersonsName". If the name is Rich Giles, only the Rich gets passed to the second form. There are several fields that have more than one word in them.

An example of the script is:

my $personname;

$personname="Rich Giles"; (it fails even if I hard code the value in)

print "All the page required lines"
print '<body>';
print '<form name="entry" method="POST" action="https://creditcardco.com/pay.cgi">';
print "<input type='hidden' name='card-name' value= $personname>";
print "<input type='submit' name='Button' value='CLICK HERE TO PROCESS THE PAYMENT' />";


The resulting form only shows "Rich".
If I hard code "Rich Giles" into the "card-name" input line, both words are passed.
If I cause $personname to print on the second web page it prints "Rich Giles"
If I remove the type='hidden' from the "card-name" input line so I can see the value setting there before I click submit, what shows is "Rich" only.

Is there something I need to know about scaler variables and building a web form in Perl?

Thanks
Rich
Reply With Quote
  #2 (permalink)  
Old 03-02-11, 10:43 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You need to quote the value or the interpreter will terminate after encountering a space.
This behavior will happen in most languages.
When the variable isn't quoted it will be interpreted as an integer.
As soon as it encounters a space it figures that is the end of the integer.
When you quote it, it will interpret it as a string.

I have noted that this behavior happens primarily when a variable/value is being inserted into an input element.

These two methods will print the same results:

print "<input type='hidden' name='card-name' value=Rich Giles>";
print "<input type='hidden' name='card-name' value=$personname>";

And these methods are correct:

print "<input type='hidden' name='card-name' value='Rich Giles'>";
print "<input type='hidden' name='card-name' value='$personname'>";
__________________
Jerry Broughton

Last edited by job0107; 03-02-11 at 11:01 AM.
Reply With Quote
The Following User Says Thank You to job0107 For This Useful Post:
GRichG (03-02-11)
  #3 (permalink)  
Old 03-02-11, 10:59 AM
GRichG GRichG is offline
New Member
 
Join Date: Mar 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Thank you so much.........
Perl is not my language, nor is anything Unix for that matter.

That did fix the dilima.
Rich
Reply With Quote
Reply

Bookmarks

Tags
scaler


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nixism | Affordable/Reliable Web Hosting: cPanel, Fantastico, PHP 5, Ruby.. more!! .amaZe General Advertisements 0 06-04-07 08:02 PM
Switch over to WireNine.com Web hosting today! WireNine.com General Advertisements 0 06-21-06 09:44 AM
Outsourcing web design to Bulgaria - Marin Todorov gal_flower Job Offers & Assistance 4 02-14-06 08:05 PM


All times are GMT -5. The time now is 04:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.