Closed Thread Icon

Preserved Topic: CGI form Input... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17804" title="Pages that link to Preserved Topic: CGI form Input... (Page 1 of 1)" rel="nofollow" >Preserved Topic: CGI form Input... <span class="small">(Page 1 of 1)</span>\

 
foam
Bipolar (III) Inmate

From: Fontana, Ca, USA
Insane since: Jun 2000

posted posted 06-15-2000 19:44

Hey, I am trying to make a new cgi/perl program that will take the inputed data from a FORM i made, and put it into a txt file. For a news/updates thing on my site...Then have an SSI on a .shtml file that will bring it into the certain DIV on my page.
I wanna know how to get form input in a CGI program, like action="cgiprog.cgi" ok? i need to be able to control each indivdual input form, cause im making a news thing, so i gotta move it around...How do i get from a form and write to a txt file? i know how to write to a txt file, but i cant get the damn form info in perl...

please help, thanks alot!

foam
www.thefoam.org

foam
Bipolar (III) Inmate

From: Fontana, Ca, USA
Insane since: Jun 2000

posted posted 06-15-2000 20:52

Wait, i think i MAY have it, can someone look at this and tell me if its the right way?:

#!/usr/bin/perl
use CGI;

$cgiobject = new CGI;

#gets the values, i hope

$name=$cgiobject->param("username");

$email=$cgiobject->param("email");


is that right? then i just open the text file i wish for it to go to right? Then when its open, i make the whole text document into some variable ($news) then i have the program write to the txt file like so:

print "<tags with things in it>$name, $email"

print "\n $news"

then save the file then close it right?

thanks.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-15-2000 22:09

Yup you pretty much have it. usually When I use the CGI perl module I dump all the info into an array like this:

@names = $query->param;

then I can print each of them like this:

foreach $name (sort @names) {
print MAIL "\n\n$name:\n"; #prints the name of the form element;
print MAIL $query->param($name);#prints the value;
}

(In this case I am writing to an email but I could be writing to a text file.)

Or you can go refrence each by their name:
print MAIL $query->param('whatever') you don't necessarily need to assign each param to a variable (unless you are doing a lot of manipulation with the data in which case it may be easier)

Anyways this should work
#!/usr/local/bin/perl

use CGI;
$query = new CGI;
@names = $query->param;

open WHATEVER,"> whatever.txt"

foreach $name (sort @names) {
print whatever $query->param($name);
}

Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 06-15-2000 22:17

Can two actions be passed on post in a Form tag?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-15-2000 23:46

Hmm I don't think so but threre are a couple off work-arounds, First, is combine the two scripts. I'm not really why you want two in the first place so this is my best suggestion. Take the info/data and do everything you want to it in one script. However if you do need two use 2 scripts you have a couple of ways to go, you could use javascript to do it (you may need to use some frames or a different window or something) remember the Action attribute actually sends the client to that file with the package of data he enters into the form so you can't send him to two places in the same browser window but you could do it with a hidden frame.

You could also have the first script run the second or vice versa. Or finally you could have one script push the client on to the other one automatically at the end.

Does that help at all?? If you explained what you are trying to do maybe I could help better



Walking the Earth like Kane

Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 06-16-2000 00:20

Scenario:

user enters name,email,date,message into form then hits 'submit'. I need the submitted data to write to a txt file (I've already got this part working) and I need for an email to be sent with the 'submit'ted data back to my email account all in one fell swoop of the 'submit' button.

Perhaps on 'submit' an email could write to the text file and 'cc' me? Would that be a work around?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-19-2000 20:32

Okay, Boudga, Did you get the CGI.pm yet?


Walking the Earth like Kane

« BackwardsOnwards »

Show Forum Drop Down Menu