Re: Can't seem to transfer a dynamically chosen parameter to next page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/3/17 Bill Mudry <billmudry@xxxxxxxxxx>
>
> I hope someone has an answer to what has been a thorny problem for me. I am still junior to using PHP.
> I have a script that displays a bunch of woody botanical orders out of a MySQL file nicely in columns.
> That part works fine.
>
> Next what is wanted is for a user to be able to click on one of them, the result being that it would open up
> a new page that would get details on the woody order the person chose out of another MySQL table.
> Well .... I got it to link to a page that opens up ok ---- except after numerous attempts and ways I cannot
> get the name of the chosen woody order to transfer to this next page.
>
>        - the examples I have seen on the Internet and book use static information for the better part while the
>          very parameter that needs to be passed is derived dynamically. I am fairly sure that is complicating
>          things more.
>
>        - Cookies would be an overkill and have too much persistence. I believe using "session" would be overkill,
>          too, even if it might work. All I need is to make the choice the reader makes go global enough to use it
>          in the very page that it calls. It is then also used both for titles on that page (dynamic) and to do a
>          query for information to display on that chosen order. Writing to a file seems to be an inefficient way if
>          there is only a way to just make it be memory resident instead.
>
> The running copy can be seen and tried (to the degree it is working so far) at:
>        http://www.prowebcanada.com/taxa/viewallorders.php
>
> The files used are viewallorders.php and the response page of showorder.php. I will add these as attachments.
>
> What *will* work? Hope someone can help.

What *will* work is understanding how HTTP works and where variables
come from within a script. For this you need to read up on it - I'm
sure Google can find you a basic introduction to web development.

As for your current problem please ignore all talk of JS and forms,
neither of which are needed. In viewallorders.php where you have...

    echo "<a href='showorder.php?$name '>";

...change it to...

    echo "<a href='showorder.php?ordername=".urlencode($name)."'>";

Then in showorder.php that value will be available in
$_GET['ordername'], so for example your debugging statement would
change from...

    echo "Debug statement: Chosen order is . $ordername . $name";

...to...

    echo "Debug statement: Chosen order is ".htmlentities($_GET['ordername']);

Notice how I'm encoding the value going into the URL and escaping it
when it gets echo'd back to the browser. This is important for
security reasons. For more on that please read
http://phpsec.org/projects/guide/.

-Stuart

-- 
http://stut.net/

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux