call back to my own script

call back to my own script

am 20.01.2008 21:39:35 von burrell.john

Hi,
I have the following code
I want to call back to the same cgi code on the same server - but on
submit I merely get the relative path appended to the original URL.
How to fix?

TIA

J

#!/usr/bin/perl
use strict;
use warnings;
use CGI ':standard';
print header,
start_html('Enter Logon Details'),
h1('Enter Logon Details`'),
h1($MyId),
start_form,
"What's your name? ",textfield('name'),p,
"What's your password? ",textfield('password'),p,
submit,
end_form,
hr;

Re: call back to my own script

am 21.01.2008 00:19:33 von Tad J McClellan

burrell.john@yahoo.com wrote:


> #!/usr/bin/perl
> use strict;
> use warnings;
> use CGI ':standard';
> print header,
> start_html('Enter Logon Details'),
> h1('Enter Logon Details`'),
> h1($MyId),


Global symbol "$MyId" requires explicit package name at ...


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Re: call back to my own script

am 21.01.2008 03:25:30 von Gunnar Hjalmarsson

burrell.john@yahoo.com wrote:
> I have the following code

I notice that you are using CGI.pm's start_form() method.

> I want to call back to the same cgi code on the same server -

That's what should happen when start_form() is called without
parameters, as in your case.

> but on
> submit I merely get the relative path appended to the original URL.

I'm not able to reproduce that behaviour. Can you give us more details?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: call back to my own script

am 21.01.2008 10:42:02 von burrell.john

On 21 Jan, 02:25, Gunnar Hjalmarsson wrote:
> burrell.j...@yahoo.com wrote:
> > I have the following code
>
> I notice that you are using CGI.pm's start_form() method.
>
> > I want to call back to the same cgi code on the same server -
>
> That's what should happen when start_form() is called without
> parameters, as in your case.
>
> > but on
> > submit I merely get the relative path appended to the original URL.
>
> I'm not able to reproduce that behaviour. Can you give us more details?
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Thanks for your help! Added an action param to start_form!Got further
now.
However the URL I have contructed does not contain the values captured
by the pop up.
http://192.168.1.21/cgi-bin/tool4.cgi?LinkId=36633&Password= param('password')&Username=param('name')
Anyone like to help?
TIA

J

use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use CGI::Pretty;

use Digest::MD5 qw(md5 md5_hex md5_base64);
my $LinkId = param( 'LinkId' );
print header,
start_html('Enter Logon Details'),
h1('Enter Logon Details`'),
h1($LinkId),
start_form (-action => "http://192.168.1.21/cgi-bin/tool4.cgi?
LinkId=${LinkId}&Password=param('password')&Username=param(' name')"),
"What's your name? ",textfield('name'),p,
"What's your password? ",textfield('password'),p,
submit,
end_form,
hr;
my $digest = md5(param('password'));

Re: call back to my own script

am 21.01.2008 13:01:02 von Tad J McClellan

burrell.john@yahoo.com wrote:
> On 21 Jan, 02:25, Gunnar Hjalmarsson wrote:
>> burrell.j...@yahoo.com wrote:
>> > I have the following code
>>
>> I notice that you are using CGI.pm's start_form() method.
>>
>> > I want to call back to the same cgi code on the same server -
>>
>> That's what should happen when start_form() is called without
>> parameters, as in your case.
>>
>> > but on
>> > submit I merely get the relative path appended to the original URL.
>>
>> I'm not able to reproduce that behaviour. Can you give us more details?
>>
>> --
>> Gunnar Hjalmarsson
>> Email:http://www.gunnar.cc/cgi-bin/contact.pl


It is bad form to quote .sigs.


> Thanks for your help! Added an action param to start_form!Got further
> now.
> However the URL I have contructed does not contain the values captured
> by the pop up.
> http://192.168.1.21/cgi-bin/tool4.cgi?LinkId=36633&Password= param('password')&Username=param('name')


Form values only go in the URL for HTTP GET requests.


> Anyone like to help?


You can help yourself by reading the documentation for the function
that you are using.

start_form() defaults to making an HTTP POST request, where the form
values go to STDIN rather than to the env var that contains the URL.

You need to give start_form() a "-method=>'GET'" argument as well
as an "-action" argument.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Re: call back to my own script

am 21.01.2008 16:40:59 von philip.kingsten

On 21 Jan, 12:01, Tad J McClellan wrote:
> burrell.j...@yahoo.com wrote:
> > On 21 Jan, 02:25, Gunnar Hjalmarsson wrote:
> >> burrell.j...@yahoo.com wrote:
> >> > I have the following code
>
> >> I notice that you are using CGI.pm's start_form() method.
>
> >> > I want to call back to the same cgi code on the same server -
>
> >> That's what should happen when start_form() is called without
> >> parameters, as in your case.
>
> >> > but on
> >> > submit I merely get the relative path appended to the original URL.
>
> >> I'm not able to reproduce that behaviour. Can you give us more details?
>
> >> --
> >> Gunnar Hjalmarsson
> >> Email:http://www.gunnar.cc/cgi-bin/contact.pl
>
> It is bad form to quote .sigs.
>
> > Thanks for your help! Added an action param to start_form!Got further
> > now.
> > However the URL I have contructed does not contain the values captured
> > by the pop up.
> >http://192.168.1.21/cgi-bin/tool4.cgi?LinkId=36633&Password =param('pa...)
>
> Form values only go in the URL for HTTP GET requests.
>
> > Anyone like to help?
>
> You can help yourself by reading the documentation for the function
> that you are using.
>
> start_form() defaults to making an HTTP POST request, where the form
> values go to STDIN rather than to the env var that contains the URL.
>
> You need to give start_form() a "-method=>'GET'" argument as well
> as an "-action" argument.
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"- Hide quoted text -
>
> - Show quoted text -
Thanks - have read the docs a couple of times - lack some
understanding I am afraid

print header,
start_html('Enter Logon Details'),
h1('Enter Logon Details`'),
h1($LinkId),
start_form (-action => "http://192.168.1.21//cgi-bin/tool3.cgi?
LinkId=$LinkId", -method=>'GET'),
"What's your name? ",textfield('name'),p,
"What's your password? ",textfield('password'),p,
submit,
end_form,
hr;
However the URL that gets built mysteriouly contains the name and
password that I entered + submit+Query no sogn of LinkId though
http://192.168.1.21://cgi-bin/tool3.cgi?name=fred&password=b ert&.submit=Submit+Query

Strange?

Re: call back to my own script

am 21.01.2008 16:58:25 von Joost Diepenmaat

philip.kingsten@yahoo.com writes:
> Thanks - have read the docs a couple of times - lack some
> understanding I am afraid
>
> print header,
> start_html('Enter Logon Details'),
> h1('Enter Logon Details`'),
> h1($LinkId),
> start_form (-action => "http://192.168.1.21//cgi-bin/tool3.cgi?
> LinkId=$LinkId", -method=>'GET'),
> "What's your name? ",textfield('name'),p,
> "What's your password? ",textfield('password'),p,
> submit,
> end_form,
> hr;
> However the URL that gets built mysteriouly contains the name and
> password that I entered + submit+Query no sogn of LinkId though
> http://192.168.1.21://cgi-bin/tool3.cgi?name=fred&password=b ert&.submit=Submit+Query
>
> Strange?

I don't feel like looking it up, but I guess that submitting the form as a
GET request clobbers any arguments specified in the action.

You really shouldn't use GET on a login form anyway. See the relevant
parts of the CGI/HTTP specs.

So, use POST and/or put LinkId in a hidden field.

Joost.