You are here: Re: Undefined Index « PHP Programming Language « IT news, forums, messages
Re: Undefined Index

Posted by Kimmo Laine on 09/20/06 06:08

"Dave Kelly" <daveekelly@earthlink.net> wrote in message
news:0M2Qg.3763$UG4.481@newsread2.news.pas.earthlink.net...
> Reference the above thread: "Passing a HTML variable to a PHP file
> using include". One thing I've learned over the years is that an error
> doesn't always come from where the compiler/interperture says it does.
> Case in point maybe.
>
> I am getting this error:
>
>
> Notice: Undefined index: var1 in
> /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 4
>
> Warning: fwrite(): supplied argument is not a valid stream resource in
> /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 5
>
> Warning: fclose(): supplied argument is not a valid stream resource in
> /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 6
>
> in this function:
>
> <?php
> if($_GET["op"] == "ds") {
> foreach ($_GET["name"] as $key=>$value) {
> $fp=fopen($_GET["var1"],"a");
> fwrite($fp,$_GET["name"][$key] ."&nbsp;". $_GET["email"][$key]
> ."&nbsp;". $_GET["phone"][$key] ."&nbsp;". $_GET["id"][$key]);
> fclose($fp);
> }
> }
> ?>
>
> 'var1' comes from this last line in this snippet in a previous function:
>
> <html>
> <body>
> <?php include ($_GET["var2"]); ?> // this works
> <br clear="all">
> <?php include ($_GET["var1"]); ?> //this works
> <form action="form.php?var1=>($_GET["var1"])" method="GET"> // NOT


Since the form method is GET, it will replace any existing get parameters in
the form action. Use a hidden field in the form instead:

<input type="hidden" name="var1" value="<?php echo $_GET["var1"] ?>">

Dunno what the heck this var1=>($_GET["var1"]) syntax is, smarty perhaps, I
don't know cos I've never used it, but I assume you understand my example
and can adjust it to meet your requirments..

Get parameters in form action work only if the form method is POST...

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация