Re: Display the data passed from php
by moritz (Cardinal) on Aug 20, 2007 at 08:58 UTC
|
What do you mean by The contents of whole page is displayed in the browser?
Are the contents of the perl script displayed in the browser, insted of its output? If that's the case, you have a problem with the configuration of your webserver, not with perl.
And a general hint: to ease debugging of CGI scripts, start them with
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Carp qw(fatalsToBrowser);
And print the header as soon as you can.
| [reply] [Watch: Dir/Any] [d/l] |
|
Yes the contents are displayed instead of output.
Should I specify the path of cgi-bin where it is installed.
Cgi-bin directory is in /var/www/cgi-bin which is the path of the server.
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|
|
$chmod +x mail_contact.pl
| [reply] [Watch: Dir/Any] [d/l] |
|
|
Re: Display the data passed from php
by Gangabass (Vicar) on Aug 20, 2007 at 08:50 UTC
|
Usually CGI scripts are placed in cgi-bin directory (with 755 access rights).
So your form must look like
<form method="get" action="/cgi-bin/mail_contact.pl" onsubmit="return
+validate()">
Also don't forget to add
#!/usr/bin/perl -w
in the first line of your script (to tell server where the perl is) | [reply] [Watch: Dir/Any] [d/l] [select] |
|
When I added the /cgi-bin/mail_contact.pl in form
Got the output as
The requested URL /cgi-bin/mail_contact.pl was not found on this serve
+r.
----------------------------------------------------------------------
+----------
Apache/2.0.52 (Red Hat) Server at xxx.xxx.xx.x Port 80
| [reply] [Watch: Dir/Any] [d/l] |
|
Do you have mail_contact.pl in your /cgi-bin directory?
| [reply] [Watch: Dir/Any] |
|
Re: Display the data passed from php
by ww (Archbishop) on Aug 20, 2007 at 12:58 UTC
|
Further questions -- for consideration once you've sorted out your permissions issues:
1) Is the "onsubmit="return validate()" calling javascript properly -- ie, is the "return validate()" in the same page with the form? Is the validation returning what you expected? (My js fu is very weak, but the space in that function name makes me itch). update Same question if you're calling a php function, if that's the case, as belated reconsideration suggests?
2) When you see the script returned in your browser, does the address bar include the name-value pairs you think you're submitting?
3) (Style, perhaps) Is there are reason you're using "get rather than "post" in the form?
| [reply] [Watch: Dir/Any] |
Re: Display the data passed from php
by rvosa (Curate) on Aug 21, 2007 at 18:21 UTC
|
If the script's contents are returned (i.e. a bunch of perl code), your webserver is treating the script as a text file, not as something to execute. You have to do two things: i) tell your webserver the script is to be executed ii) make the script executable.
Step i) is achieved by doing something like placing the script in a default cgi-bin folder, or changing your server's configuration so that it understands the file extension of things that are to be used as cgi executables (though outside the cgi-bin), such as *.pl or *.cgi. Step ii) is achieved by doing something like chmod +x mail_contact.pl.
We can't really be more specific because we don't know (or particularly care about, since this is not an apache/php/js forum) your exact server configuration. | [reply] [Watch: Dir/Any] [d/l] |