473,473 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Web form: Frustrating problem

20 New Member
Hi everyone,

I'm writing a web form and a backend Perl script to send a query to the administrator.

V1 of the script is working well, it's basically just a simple get-data-send-email [sendmail] script. V2, on the other hand, is a nightmare. I added just a few changes.

In the HTML page (which has become an SHTML page to support a server includes:

Expand|Select|Wrap|Line Numbers
  1. <form method="post" onsubmit="return checkform()" action="/cgi-bin/activate_v2.pl" >
  2.  
  3. <input type="hidden" id="ip" value="127.0.0.1" />
  4.  
In the javascript:

Expand|Select|Wrap|Line Numbers
  1. /* New code: Gets IP address using SSI */
  2. var ip = '<!--#echo var="REMOTE_ADDR"-->';
  3.  
  4. /* New code: Adds IP address to hidden field */
  5. document.getElementById("ip").value = ip;
  6.  
In the Perl:

Expand|Select|Wrap|Line Numbers
  1. my $ip = "127.0.0.1";
  2.  
  3. $ip = param('ip');
  4.  
  5. # now we can check the data
  6.  
  7. if ($fullname eq "" || $address eq "" || $username eq "" || $sender eq "") {
  8.  
  9.     # we have incomplete data, so we will serve an error
  10.  
  11.     # set the web page parameters
  12.  
  13.     $content_header = 'Incomplete Information';
  14.     $content = '<p>Your activation request not been submitted.</p> <p>You did not fill out all of the requested information on the previous page. Please return to the main activation page and complete the form as directed.</p> <p>If you feel that you received this message in error, please <a href="mailto:admin@our-website.com">email the web services administrator</a>.</p>';
  15.     $site_url = '/activate/';
  16.     $link = 'Click here to return to the previous page';
  17.  
  18.     # $activate = 0;  # not needed as this parameter was set at the beginning
  19.  
  20. }
  21.  
  22. else {
  23.  
  24.     # everything is okay
  25.     $activate = 1;
  26.  
  27. if ($activate == 1) {
  28.  
  29.     # it's okay to submit the request
  30.  
  31.  
I'm completely lost (as evidenced by my previous, late unlamented post...).

I should mention that I have tried changing the POST method to GET to try and see what is passed to the script, but nothing seems to be being passed over.

Also, I originally broke the code up into subroutines, but when the program didn't work I lumped it all back together again for troubleshooting purposes.

Perhaps I should break this problem into two and try to run the Perl script from the shell? How can I pass parameters to the script (i.e. "ip", "fullname" etc.)?
Mar 28 '07 #1
11 1603
davidiwharper
20 New Member
I should mention the actual problem I guess: I always get the error page, not the success page. When I've tried printing the variables (ip, fullname etc) collected at the beginning of the script to the screen (the HTML page), they display as blank.
Mar 28 '07 #2
KevinADC
4,059 Recognized Expert Specialist
one of these conditions is true so your script does the error stuff:

Expand|Select|Wrap|Line Numbers
  1. if ($fullname eq "" || $address eq "" || $username eq "" || $sender eq "") {
but there is no way to tell by looking at the code or from anything you said to know why that is. Are the above variables getting defined somewhere? Print them out to the screen to see what their values are.
Mar 28 '07 #3
davidiwharper
20 New Member
Indeed, unfortunately all of them are true. The problem is I don't know why.
Mar 30 '07 #4
KevinADC
4,059 Recognized Expert Specialist
The obvious question is: where are these variables being defined?

Expand|Select|Wrap|Line Numbers
  1. if ($fullname eq "" || $address eq "" || $username eq "" || $sender eq "") {
are they data from a form? Where is the data from the form getting put into those variables?
Mar 30 '07 #5
davidiwharper
20 New Member
On the form:

Expand|Select|Wrap|Line Numbers
  1. <form method="post" onsubmit="return checkform()" action="/cgi-bin/activate_v2.pl" >
  2.  
  3. <input type="hidden" id="ip" value="127.0.0.1" />
  4.  
  5. <p><table>
  6. <tr>
  7.     <td>Full Name:</td>
  8.     <td><input type="text" id="fullname" size="31" /></td>
  9. </tr>
  10. <tr>
  11.     <td>Street Address:</td>
  12.     <td><input type="text" id="address" size="31" /></td>
  13. </tr>
  14. <tr>
  15.     <td>Email Address:</td>
  16.     <td><input type="text" id="email" size="31" /></td>
  17. </tr>
  18. <tr>
  19.     <td>Website User Name: </td>
  20.     <td><input type="text" id="username" size="31" /></td>
  21. </tr>
  22. </table></p>
  23.  
  24. <p><button type="submit">Submit</button></p>
  25.  
  26. </form>
  27.  
There's also a smigden of Javascript to alter the 'ip' hidden field, which I have noted in my first post.

From the Perl script:

Expand|Select|Wrap|Line Numbers
  1. my $sender = 'noreply@our-website.com';
  2. my $fullname = '';
  3. my $address = '';
  4. my $username = '';
  5. my $ip = "127.0.0.1";
  6.  
  7. ### some other stuff, not posted ###
  8.  
  9. # gets data from the initial HTML form
  10.  
  11. # get all of the form contents
  12.  
  13. my $formcontents = "";
  14.  
  15. foreach my $field (param) {
  16.  
  17.     foreach my $value (param($field)) {
  18.  
  19.         $formcontents.= "$field: $value\n";
  20.  
  21.     }
  22. }
  23.  
  24. # now let's get the values from the form
  25.  
  26. $fullname = param('fullname');
  27.  
  28. $address = param('address');
  29.  
  30. $sender = param('email');  # no need for a my statement
  31.  
  32. $username = param('username');
  33.  
  34. $ip = param('ip');
  35.  
Mar 31 '07 #6
KevinADC
4,059 Recognized Expert Specialist
hard to tell, it's like trying to diagnose a patient when all you can see is an arm or a leg. Assuming your script has loaded the CGI module and the form fields are filled in, I can't see why the script doesn't seem to work right.
Mar 31 '07 #7
davidiwharper
20 New Member
The problem is almost certainly in the changes I quoted at the beginning, V1 has none of these issues.

But for the life of me I am stuck, and my teacher is as well. Looks like the script needs to be scrapped and I will have to do without the server-side error checks.

Thanks.
David
Mar 31 '07 #8
KevinADC
4,059 Recognized Expert Specialist
Try removing this part of the code

Expand|Select|Wrap|Line Numbers
  1. foreach my $field (param) {
  2.  
  3.     foreach my $value (param($field)) {
  4.  
  5.         $formcontents.= "$field: $value\n";
  6.  
  7.     }
  8. }
it might be emptying the buffer so subsequent attempts to get data out of param() might be empty.
Mar 31 '07 #9
davidiwharper
20 New Member
Sorry about the delay in posting -- exams.

Great idea, but this didn't work. Thanks for the suggestion, any more? (hoping against hope here)

If you're ever in Australia look me up and I'll buy you a beer, heh... you deserve it, mate :-)
Apr 4 '07 #10
KevinADC
4,059 Recognized Expert Specialist
print $formcontents out to a file or the screen and report back what it's value is.


Expand|Select|Wrap|Line Numbers
  1. foreach my $field (param) {
  2.  
  3.     foreach my $value (param($field)) {
  4.  
  5.         $formcontents.= "$field: $value\n";
  6.  
  7.     }
  8. }
Apr 4 '07 #11
davidiwharper
20 New Member
$formcontents is blank:

Form Contents:
There is literally no content, specifically no undef message. Just before the code you quoted, I defined $formcontents as "".

Thank you for your continued help with this.

David
Apr 6 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Programatix | last post by:
Hi, I'm working on a project which includes XML WebServices and Windows Form application. The Windows Form application will call the XML WebServices to retrieve data from database. The data...
4
by: Jonathan Strange | last post by:
I have a website that uses Forms, and if I complete the form fields, submit the form, realise that there was an error or omission, and then hit the Back button, the form fields are all empty. This...
8
by: Neil | last post by:
I have a very puzzling situation with a database. It's an Access 2000 mdb with a SQL 7 back end, with forms bound using ODBC linked tables. At our remote location (accessed via a T1 line) the time...
3
by: dixie | last post by:
I have an Access 2000 form which has been running OK for a long time. Lately, it is playing up and doing things like causing Access to close suddenly when the form is opened or when saving the form...
3
by: Junkguy | last post by:
Hi, I'm having a problem in Visual Studio in C#, using .NET Framework 1.1 Version 1.1.4322 and Microsoft Development Environment 2003 Version 7.1.3088 I make a form A and subclass it with form...
9
by: Param R. | last post by:
Hi all, we have a few apps running on server 2003 with .net 1.1 sp1. Simple web forms with db backend. Websites run over SSL with client certs. Clients are Windows XP SP2 with all updates and IE....
4
by: Baz | last post by:
Hi. I'm new to this VB.Net mullarkey, and I must say it is proving to be a very trying experience. Here is the latest in a long line of problems: The Scenario ========= I am building an...
3
by: bosmatthews | last post by:
I have a main form with a subform and a second subform nested to the first subform. The data entry property for all three forms (main, subform and sub-subform) is set to "yes" because I am intending...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
1
by: tash.robinson | last post by:
I have a modal form called like: myKeyboard.ShowDialog(Me) If myKeyboard.DialogResult = Windows.Forms.DialogResult.OK Then result = myKeyboard.txtEntry.Text Else result = defaulttext End If
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.