FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 05-26-2018, 01:33 PM   Postid: 186538
ricktrip
Site Owner
 
ricktrip's Avatar

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Oct 2003
Posts: 81
Form action attribute

This will seem like a simple question to most of you, but I'm at a low level of skill. My question is how to properly express a url in the action of a form. Currently I have

Code:
action="http://www.exploringmyself.com/cgi-bin/student_login.cgi" method="post"
which works fine. But I want to change it so it will work on any of my different websites, all hosted at FutureQuest. I vaguely understand relative addressing and could probably do this if the url pointed to one of my WWW pages, but it must point to the cgi-bin.

I this possible?
ricktrip is offline   Reply With Quote
Old 05-26-2018, 01:40 PM   Postid: 186539
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,986
Re: Form action attribute

A URL can be as short as a file name (relative to the file containing it) or it can be a /path/filename relative to the host of the file containing it. Also, CGI scripts don't have to be in cgi-bin. They will work in www if you name them whatever.cgi and mark them executable. In fact, if you name them index.cgi then they will run if the URL is a directory.
__________________
Kevin
Kevin is offline   Reply With Quote
Old 05-26-2018, 01:46 PM   Postid: 186540
ricktrip
Site Owner
 
ricktrip's Avatar

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Oct 2003
Posts: 81
Re: Form action attribute

Wow! This is interesting; thanks, Kevin!

It does raise two questions in my mind (1) is there a security risk in placing executable code under the WWW level? and (2) is there no way to reference the code if I leave it in the cgi-bin?
ricktrip is offline   Reply With Quote
Old 05-26-2018, 01:51 PM   Postid: 186541
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,986
Re: Form action attribute

Security wise it is the other way around. Everything in cgi-bin is treated as a CGI script whether it is or isn't so putting extra files in there can be dangerous. As far as executable stuff in www that is how php works anyway.

A form on http://www.exploringmyself.com/ can reference http://www.exploringmyself.com/cgi-b...dent_login.cgi as just /cgi-bin/student_login.cgi since it is relative to the site.
__________________
Kevin
Kevin is offline   Reply With Quote
Old 05-26-2018, 01:55 PM   Postid: 186542
ricktrip
Site Owner
 
ricktrip's Avatar

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Oct 2003
Posts: 81
Re: Form action attribute

Excellent! You've raised my level of understanding and given me new avenues to explore. I am look forward to the adventure!
ricktrip is offline   Reply With Quote
Old 06-17-2018, 03:20 PM   Postid: 186560
ricktrip
Site Owner
 
ricktrip's Avatar

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Oct 2003
Posts: 81
Re: Form action attribute

This is the tail end of a perl subroutine in which I’ve experimented in defining $path with limited success. I’ve commented out all the experimental lines, though the first two work just fine. The third line works in the action of a form and in links, as Kevin helpfully explained above; but it does not work when passed to Template Toolkit (TT).

I know that TT doesn’t require an absolute address, since the two lines starting with usr below are taken from the TT book. The tilde is just something I saw in another book.

Either I’m wrong in assuming that /www is sufficient to define a path relative to the top of my FQ website, or TT is picky about how I give it information.

I’m sure I’m making a simple blunder, but I’m not a computer professional, and I get confused often. Any advice will be appreciated; thanks!

Code:
    # Call Template Toolkit
    local $| = 1; # auto flush buffer
#    my $path = '/big/dom/xexploringmyself/www/templates';  # works
#    my $path = '/big/dom/x'. $server .'/www/templates';    # works
#    my $path = '/www/templates'; # works in form action and links, but fails here
#    my $path = './www/templates';                          # fails
#    my $path = '../www/templates';                         # fails
#    my $path = 'www/templates';                            # fails
#    my $path = 'usr/local/www/templates';                  # fails
#    my $path = 'usr/www/templates';                        # fails
#    my $path = '~/www/templates';                          # fails
    my $tt = Template->new(
        {INCLUDE_PATH => "$path"}
    );
    my $input = 'open_courses.html';
    my $vars = {
                student_id  => $student_id,
                name_full   => $student_info_hash{name_full},
                courses     => \%row_data
    };
    print "Content-Type: text/html\n\n";
    $tt->process($input, $vars) 
        or die $tt->error();
}
ricktrip is offline   Reply With Quote
Old 06-17-2018, 05:57 PM   Postid: 186561
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,986
Re: Form action attribute

As you have discovered the real absolute path is /big/dom/xexploringmyself/www/templates. That could also be described as ~/../www/templates since your '~' is /big/dom/xexploringmyself/ricktrip.

Relative links are always more complicated since you have to know the working directory that the script is running in. The easiest way to find that out is to have perl run /bin/pwd and see what it says.
__________________
Kevin
Kevin is offline   Reply With Quote
Old 06-18-2018, 12:40 PM   Postid: 186562
ricktrip
Site Owner
 
ricktrip's Avatar

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Oct 2003
Posts: 81
Re: Form action attribute

Whoa! Useful AND interesting! Thank you, Kevin!
ricktrip is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:22 AM.


Running on vBulletin®
Copyright © 2000 - 2019, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2019 FutureQuest, Inc.
FutureQuest, Inc.