how would i take a variable from one file and send it to another file. Is there some type of memory that i can store it in and then get another program to call it?
Basicaly all i want to do is get a user name which was inputed through one cgi file and stored into a variable and send that user name to another file.
Thankyou
here is where it leads to:
#!c:/perl/bin/perl.exe
#START
#
#-----------LOGIN_SCRIPT_FOR_NEWS--------------
#
# created by Mark Y. (DRT_Phobia)
#
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
my $theplace='addcontent.cgi';#the place that gets $user
my ($user,$pw,$reg);
my %drts='phobia'=>'mark','matt'=>'matt',
'loc'=>'loc','twistedlady'=>'twistedlady');
$user=param('user');
$pw=param('pass');
$reg=$drts{$user};
#
if (($pw eq '') || ($user eq '')){
print "Content-type: text/html\n\n";
print "<html><body>";
print "missing user name (and) or password";
}elsif ($pw eq $reg) {
print "Content-type: text/html\n\n";
print "<html><body>";
print "Logged on! <b>$user</b><br><br>";
#<----
print "<form action=$theplace method=post>";
print "<input type=submit value=Continue>";
print "</form>";
i never thought of that. ill try it, but going into cookies just for one little variable
i did try a txt file too. I just want to fine the shortest way possible. There just has to be some kind of way to make a variable global from one CGI program to another...
Well, You have two ways: you can create the file and write your variable into it or open a socket and send the variable to your other script (but it must be hosted on server) by get method.
i started playing with is before, but then i got lost and started to look for an alternative. ill just post the thing i made:
Code:
#!c:/perl/bin/perl.exe
#START
#----------------------------------------------------------------------------------
#-----------ADD_CONTENT_SCRIPT_FOR_NEWS--------------
#----------------------------------------------------------------------------------
# created by Mark Y. (DRT_Phobia) and some people
#
#--------------INCLUDES------------------------------------------------------
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
#--//----------------------------------------------------------------------------//
#
#--------------VARIABLES-----------------------------------------------------
my $user;
my $servernews='../docs/cs_news.html';
my $internetnews='http://localhost/cs_news.html';
my ($name,$value,$aline,$buffer,@alinesotxt);
my ($sec,$min,$hour,$mday,$mon,$year_off,$junkus,$atop,$year,$min2);
my ($subject,$content,$update_info);
#--//----------------------------------------------------------------------------//
#
#
#--------get the user name from the login.cgi------GET_USER_NAME
if ($ENV{'REQUEST_METHOD'} eq 'POST') { # <--idez
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #should be name=phobia <--idez
chomp $buffer; # <--me
($name,$user)=split(/=/,$buffer); #$name=user,$value=phobia<--me
} else { # <--idez
$user=$ENV{'QUERY_STRING'};} # <----idez
#----------------------------------------------------------/GET_USER_NAME
#
#
#--------Time-formating-----------------------------------TIME_FORMAT
($sec,$min,$hour,$mday,$mon,$year_off,$junkus,$junkus,$junkus)=localtime;
#
$year=($year_off+1900);
#
if ($hour>12){
$atop='PM';
$hour=($hour)-12;
}else{
$atop='AM';}
#
if ($min<10){$min2='0';}
#
#----------------------------------------------------/TIME_FORMAT
#
#print "Content-type: text/html\n\n";
#print "<html><body>";
#print "</body></html>";
#
#
# ---------------------title-and-post-input-area--------------GET_POST
print "Content-type: text/html\n\n";
print "<html><body>";
print "$user $buffer";
print "
<br><br><br>$user $buffer<br>
<form action=$ method=post>
Title:<input type=text name=subject size=40
maxlength=40><br><br>
Post Information:<br><textarea name=content cols=65
rows=5 wrap></textarea><br><br><br>
<input type=submit value=submit><input type=reset value=reset>
</form>
";
print "</body></html>";
exit;
#-----------------------------------------------------------/GET_POST
#
#
#
#
#-----take form input of form and sort the string given--FIND_VAR
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
@alinesotxt=split(/&/,$buffer);
foreach $aline(@alinesotxt){
($name,$value)=split(/=/,$aline); #
$value=~tr/+/ /; //#takes out '+' which is a space and replaces it with a space
$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$value=~s/<\!\-\-\.*\-\->//g; #takes out commnets
$in{$name}=$value;
}
#------------------------------------------------------------/FIND_VAR
#
#---------open the html file and write to it-----------------------WRITE
# ---------------------> !!!! im not done this part yet !!!!
if(/<!--NEWSHERE-->/){
print NEWS"
<table border=0>
<TR>
<TD bgcolor=990000 WIDTH=25%>
$mon-$mday-$year $hour:$min2$min$atop</TD>
<TD bgcolor=990000 WIDTH=65%>
$in{'subject'}</TD>
<TD bgcolor=333333 WIDTH=10%>
$user</TD>
<TR/>
<TR><TD colspan=3>
$in{'content'}
</TD><TR/>
<hr color=black width=498>
</table>";
}
#------------------------------------------------------------/WRITE
#
#
#END
im just stuck
for some reason its not sorting the user name from the file before this one.