You are here: Re: Passing on a value to a SUBMIT button - can it be done? « PHP Programming Language « IT news, forums, messages
Re: Passing on a value to a SUBMIT button - can it be done?

Posted by Colin Fine on 10/02/05 20:02

Marcel wrote:
> "Siv Hansen" <sivh@broadpark.no> wrote in message

> Hello again,
> I've been trying to implement what was said, but it just doesn't work here..
> For the moment I go for the suggestion with a Hidden field in the form,
> because that looks the most simple one, and I'm only using this application
> at home, it's only for me and not for anybody else..
> I'm testing this in IE6 with IIS.
> Loading the page goes ok, and the pageno echoes as '1'.
> Then I hit submit, the pageno echoes as blank and I get the following
> notice: Notice: Undefined index: pageno in
> c:\\inetpub\\wwwroot\\picdata\\de2.php on line 39
>
> Here's the code:
>
> <html>
> <head>
> <title>Picture data entry</title>
> </head>
> <body>
> <div id="container">
>
> <?php
>
> /*initialize pageno */
> /* if there is a pageno then it must be one higher then the last time */
>
Here, you're checking whether there was a 'pageno' in the URL:

> if (isset($_GET['pageno']))
> {
> $pageno = $_GET['pageno'];
> $pageno = $pageno++;
> }
> else
> {
> $pageno = 1;
> }
>
> echo "pageno :" . $pageno;
>
>
> ?>
>
> <p>
> <hr align = "left">
> <table>
> <tr>
> <td align = "center" >
> <img border = "0" src = "images/01bc11.jpg ">
> </td>
> <td>
> <form method="GET" action ="de2.php?pageno=$pageno">
> <input type="text" name="pictureid" value="pictureid" READONLY>
> Picture ID <BR>
> <input type="text" name="year" value="year" READONLY> Year <BR>

but here, you're not checking it!

> <input type="hidden" name="pageno" value="<?php echo $_GET['pageno'];
> ?>">
>
> <p>
> <input type="submit" name="submit" value="Submit">
> </form>
> </td>
> </tr>
> </table>
> <hr align = "left">
> </div>
> </body>
> </html>
>
> Thanks for any suggestion...
> Marcel
>
>

You also need to think about your line
$pageno = $pageno++;

The 'post-increment operator' ++ means 'change this variable by adding
1, and then return the previous value' - so the line above has no net
effect!

Colin

 

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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация