Click to See Complete Forum and Search --> : CGI
sam0010
Jan 9th, 2001, 09:16 PM
hi i need a cgi script that will take 5 values submitted by a form and out them on one line serperated by commas in a text file like this
value1,value2,value3,value4,value5
value1,value2,value3,value4,value5
value1,value2,value3,value4,value5
and if if "value1" already exists in the text file then it replaces that line with the line being submitted! thanx
ps i have no idea how to install a cgi so please tellme as well
VIP3R
Jan 10th, 2001, 03:34 PM
u can atleast say something
Ok, first of all... what CGI language??
the most common is perl, but there is also C,C++, Python, etc..
you can also use other server side languages like PHP(my favorite), ASP, or ColdFusion.
sam0010
Jan 10th, 2001, 06:05 PM
i have no idea what im saying but i want some sort of script that will do what my 1st post says i dont know a single thing about perl and stuff but i am going to learn it once im finished with vb!!
but what language do you want it in?
Perl?
VIP3R
Jan 11th, 2001, 06:20 AM
sure
VIP3R
Jan 11th, 2001, 06:21 AM
which ever u can do it is appreciated
since I know and love PHP (:rolleyes:), I will do it in that.
here is the page with the form:
<!-- form.htm -->
<HTML>
<BODY>
<FORM ACTION="dostuff.php" METHOD="POST">
<INPUT TYPE="TEXT" NAME="V1"> <BR>
<INPUT TYPE="TEXT" NAME="V2"> <BR>
<INPUT TYPE="TEXT" NAME="V3"> <BR>
<INPUT TYPE="TEXT" NAME="V4"> <BR>
<INPUT TYPE="TEXT" NAME="V5"> <BR>
<INPUT TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>
here is the php page:
<!-- dostuff.php -->
<HTML>
<BODY>
<?php
function writetolog($logfile, $texttowrite)
{
$filenum = fopen($logfile,"a");
fwrite($filenum,$texttowrite);
fclose($filenum);
}
$str = ""; //make sure $str is empty
if (isset($V1)) $str .= "$V1,"; //if it's set, add it
else $str .= "value1,"; //if not, then do default
if (isset($V2)) $str .= "$V2,";
else $str .= "value2,";
if (isset($V3)) $str .= "$V3,";
else $str .= "value3,";
if (isset($V4)) $str .= "$V4,";
else $str .= "value4,";
if (isset($V5)) $str .= "$V5";
else $str .= "value5";
$str .= "\r\n"; //new line characters.
writetolog("val.txt", $str); //append to file
?>
</BODY>
</HTML>
to use this code, you have to have PHP installed on the machine you are trying to run it on.
VIP3R
Jan 11th, 2001, 06:43 PM
is php on everyones computer? cuz i need a script that is compatible wiht alot of computers, cuz i dont think my visitiors would have php.
VIP3R
Jan 11th, 2001, 06:46 PM
i think your code checks for every variable if its in the txt file but i only want it to check the 1st variable!
CyberSurfer
Jan 12th, 2001, 03:47 AM
PHP only needs to be installed on the Server where the script is stored (IE uklinux.net's server). The script is executed on the server, and the results are sent to your visitors computer as an ordinary HTML file. If your current host doesn't support PHP, try http://www.cfm-resources.com for some kick ass free hosting!
sam0010
Jan 12th, 2001, 03:39 PM
this is how it workes plese help me anything is apreachiated!!
lets say the 1st value is the name of a person
the 2nd value is the age fo a person and the third is the sex of the person
i want the script to search for the name only and if it findes the name then it replaces that line with the one beaing submitted
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.