So far, every time we assigned a value to a variable, it was hard coded into the script so the only way to change the starting value was to change the script. Since you are the only way to change the value, anything you make this way is only useful to you. What you need is a way to change the variable with out changing the code. That is where forms come in.
Since PHP is server side, it is a classic black box. Unless you have access to the server, you can't see what goes in, you can see what goes out but you can't see what is inside. The way forms work, is that they assign the value in them to a PHP variable with the same name. Many WebTV "tools" take advantage of that by making interfaces to tools that they couldn't make themselves. For example, take the imput page for GifWorks.. I can't see the Perl code that runs Gifworks but I can see the HTML. It may seem complex at first but all you have to do to make your own input to GifWorks is to figure out which of the three forms on that page is the URL uploader and delete everything else. Strip all the javascript and formatting that you don't need and all you have left is a small table. If a page is really complex you can also remove all the table elements to make it easier to follow and then replace them with your own simpler table. Take a look at the form "action" and If it is a relative URL, complete it to make it absolute. After a little clean up, all you have left is:
<table>
<tr><td>
<form name="imgGet" action="http://www.gifworks.com/cgi-bin/gifworks.pl" method="post">
<input type="hidden" name="site" value="">
<input type="hidden" name="com" value="transfer_get">
<input type="text" size="20" name="theimage" value="http:// maxlength="200">
<input type="submit" value="Fetch Image" />
</form>
</td>
<td></td>
</tr></table>
So what is going on inside of the black box? With something like GifWorks, you can't know exactly what is going on but the form tells you what some of the variables inside are.
Every form input has a corresponding PHP variable (or Perl in GifWorks case).
Some variables are hidden and defined in the form. The variables "theimage" and $theimage are the variables that holds the URL of the image.
| Form Variables Vs Perl Variables | |
|---|---|
| Form Variables | Perl Variables |
| site | $site |
| com | $com=transfer_get |
| theimage | $theimage=URLofImage |
|
|
|