freddiefujiwara
freddiefujiwara

Reputation: 59049

How to get variable in CGI made by /bin/sh + Apache

I'm coding following CGI script

echo "Content-type: text/html; charset=UTF-8\n\n"
echo "<HTML><HEAD><TITLE>title</TITLE></HEAD>"
echo "<BODY>"
echo "<FORM ACTION="http://exapmle.com/page2.cgi" NAME="PAGE1" METHOD="POST">"
echo "input:<INPUT TYPE=text NAME="data1" SIZE=10 MAXLENGTH=10>"
echo "<INPUT TYPE=submit NAME=nbtn VALUE='GO TO PAGE2'>"
echo "</FORM>"
echo "</BODY>"
echo "</HTML>"

How to get valiable in CGI made by /bin/sh + Apache I am glad gime me sample cord

Upvotes: 0

Views: 518

Answers (1)

slipbull
slipbull

Reputation: 1497

In the CGI script, you receive it as a parameter to main, so it should be in some place pointed by argv

Apache runs the cgi just like you:

script.cgi var1

And the parameters are in argv, so this:

printf("%s", argv[1]);

Will output

var1

Upvotes: 2

Related Questions