View Single Post

  #7 (permalink)  
Old 09-06-2004
Miffed
 
Posts: n/a
Default Re: newbie needs help with checking for posted data

"Miffed" <me@here.com> wrote in message
news:chimnf$2f2$1@newsg2.svr.pol.co.uk...
> "Michael Fesser" <netizen@gmx.net> wrote in message
> news:ljmpj0hud6ogtmlh60k5v0an3c7rrf71c4@4ax.com...
> > .oO(Miffed)
> >
> > In addition to the other reply:
> >
> > >$_POST["guess"] = (int) $_POST["guess"];

> >
> > There's no element 'guess' in the $_POST array when the script runs for
> > the first time, which causes a notice.
> >
> > Micha

>
> I didn't notice an, er, notice, but I see your point anyway.
>
> While I'm here, can you or someone else please tell me why this won't

work:
>
> <html>
> <head>
> <title>Listing 9.15 A file upload script</title>
> </head>
> <?php
> if ( isset( $_POST["fupload"] ) ) {
> // code not shown as it never executes anyway.
> }
> else // added by me to confirm test failed
> print ("not set<BR>");
> ?>
>
> <body>
> <form enctype="multipart/form-data" action="<?php print
> ($_SERVER["PHP_SELF"])?>" method="POST">
> <input type="hidden" name="MAX_FILE_SIZE" value="51200">
> <input type="file" name="fupload"><br>
> <input type="submit" value="Send file!">
> </form>
> </body>
> </html>
>
> As you'll see, this is a simple form to upload a file. Whether I send a
> file or not, the test for 'fupload' fails.


I've just worked out I have to use a $_FILES prefix, but now the test is
true even BEFORE I send a file!


Reply With Quote