|
Posted by Sandman on 09/14/05 23:29
In article <1126718878.324648.246160@g49g2000cwa.googlegroups.com>,
"sunbum" <mbrashars@gmail.com> wrote:
> Sorry for replying to my own post.
>
> Here is the latest version and I think it's closer.
>
> Can someone help me clean up the syntax?
>
> Thanks!
> ------- Code begin (this is NOT in the script ------------------
>
> <?php
> if (isset($_POST['file']))
> {
> // process the data, see if it's valid.
> // if it's valid and you're satisfied, do whatever you want with
> the data
> // if not, start outputting the form
>
> $file = "/inetpub/wwwroot/templogs/"+$_POST['file'];
> // Display the Graph
> displaygraph();
> }
>
> else {
> // display the form
> displayform();
> }
>
> <?php
> function displaygraph() {
> echo "So far so good, this would draw graph with $file";
>
> }
>
>
> ?>
>
> <?php
> function displayform() {
>
>
> <form name="cooler" action="<?php $server['PHP_SELF']?>"
> method=\"post\">";
> $dir = "/inetpub/wwwroot/templogs/";
>
> echo "<select name='file'>";
> $dir = opendir($dir);
> while (false !== ($file = readdir($dir))){
> if (in_array($file, array(".", ".."))) continue;
> print "<option value='$file'>$file</option>";
> }
> </select>;
>
>
> <input type="submit" value="Submit">;
> </form>
>
> }
>
>
> ?>
>
>
> ?>
>
> ------- Code end (this is NOT in the script ------------------
>
> Mike
The above is a good start. But you can't just start typing "<form name..."
inside a function block. You need to use
print "<form name='cooler' ....";
I always do my web app logic like this:
<?
while (1){
if ($_POST["file"]){
# Do fancy stufff
break;
}
# output form
$dir = "/inetpub/wwwroot/templogs/";
# ...
break;
}
--
Sandman[.net]
Navigation:
[Reply to this message]
|