php-windows Digest 26 Mar 2009 10:35:36 -0000 Issue 3588
Topics (messages 29208 through 29217):
Re: Can't seem to transfer a dynamically chosen parameter to next page
29208 by: Zephaniah ha Levi
29209 by: James Crow
29210 by: Zephaniah ha Levi
29211 by: Lex Braun
29212 by: James Crow
29213 by: Joao Gomes Madeira
29214 by: Stuart
29215 by: Joao Gomes Madeira
29216 by: Stuart
Where to put class files?
29217 by: John Hughes
Administrivia:
To subscribe to the digest, e-mail:
php-windows-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-windows-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-wind...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Why can you not pass the parameter in the url link of the new page using the
get variable?
Example
<form action="welcome.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
When the user clicks the "Submit" button, the URL sent could look something
like this:
http://www.w3schools.com/welcome.php?name=Peter&age=37
The "welcome.php" file can now use the $_GET variable to catch the form data
(notice that the names of the form fields will automatically be the ID keys
in the $_GET array):
Welcome <?php echo $_GET["name"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
-----Original Message-----
From: Bill Mudry [mailto:billmu...@rogers.com]
Sent: Tuesday, March 17, 2009 12:39 PM
To: php-wind...@lists.php.net
Subject: [PHP-WIN] Can't seem to transfer a dynamically chosen parameter to
next page
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.
Bill Mudry
MIssissauga, ON
--- End Message ---
--- Begin Message ---
I haven't looked at your code, but it sounds like you need JavaScript.
On the page you are going to you will need to pass something. You can
pass values either through forms or through the URL. URL may be easiest.
If you have a link like http://somehost.com/page_two.php?variable=value
you can get the variable=value part from the $_GET array. Like this
$_GET['variable'] will equal 'value'. On your first page you can then
use JS to set the url for a link to include the value you want to pass.
I don't know how involved the page is, but you can use PHP to generate
the page and create the links with the variable=value part already on
them. i.e.
<a href="http://somehost.com/page_two.php?variable=value">value</a>
<a href="http://somehost.com/page_two.php?variable=value2">value2</a>
<a href="http://somehost.com/page_two.php?variable=value3">value3</a>
<a href="http://somehost.com/page_two.php?variable=value4">value4</a>
Cheer,
James
On Tue, 2009-03-17 at 11:39 -0500, Bill Mudry wrote:
> 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.
>
> Bill Mudry
> MIssissauga, ON
> -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
--
James Crow
IT Manager
ULTRATAN, Inc.
<ja...@ultratans.com>
--- End Message ---
--- Begin Message ---
Why would you need JS to set the url for the link. Why could it not all be
done via php?
Z
-----Original Message-----
From: James Crow [mailto:ja...@ultratans.com]
Sent: Tuesday, March 17, 2009 11:59 AM
To: Bill Mudry
Cc: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Can't seem to transfer a dynamically chosen parameter
to next page
I haven't looked at your code, but it sounds like you need JavaScript.
On the page you are going to you will need to pass something. You can
pass values either through forms or through the URL. URL may be easiest.
If you have a link like http://somehost.com/page_two.php?variable=value
you can get the variable=value part from the $_GET array. Like this
$_GET['variable'] will equal 'value'. On your first page you can then
use JS to set the url for a link to include the value you want to pass.
I don't know how involved the page is, but you can use PHP to generate
the page and create the links with the variable=value part already on
them. i.e.
<a href="http://somehost.com/page_two.php?variable=value">value</a>
<a href="http://somehost.com/page_two.php?variable=value2">value2</a>
<a href="http://somehost.com/page_two.php?variable=value3">value3</a>
<a href="http://somehost.com/page_two.php?variable=value4">value4</a>
Cheer,
James
On Tue, 2009-03-17 at 11:39 -0500, Bill Mudry wrote:
> 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.
>
> Bill Mudry
> MIssissauga, ON
> -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--
James Crow
IT Manager
ULTRATAN, Inc.
<ja...@ultratans.com>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Bill,
2009/3/17 Bill Mudry <billmu...@rogers.com>
> 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.
>
In showorder.php you have:
Echo "<title>Information on ordername . $ordername"; //actual order
name still not
// transfering properly yet. Different attempts made.
Echo "</title>";
echo "Debug statement: Chosen order is . $ordername . $name"; // debig
statement only. Remove later.
$ordername has to be initialized to your query string variable. Thus,
$ordername = $_GET['name']. But this also requires a small change in
viewallorders.php so that a query string parameter of name is set:
echo "<a href='showorder.php?$name '>";
The above line should be changed to:
echo "<a href='showorder.php?name=$name'>";
-Lex
--- End Message ---
--- Begin Message ---
If you create a dynamic page with elements changing based on AJAX DB
queries and such you must be able to change the page from within the
local browser. That requires JS. I think that may be a little advanced
for what the OP was trying to accomplish, but I only mentioned it
because it can make for a more interactive page.
The example with value{2,3,4} shows how to do static links and can be
done only with PHP.
Cheers,
James
On Tue, 2009-03-17 at 12:02 -0400, Zephaniah ha Levi wrote:
> Why would you need JS to set the url for the link. Why could it not all be
> done via php?
>
> Z
>
> -----Original Message-----
> From: James Crow [mailto:ja...@ultratans.com]
> Sent: Tuesday, March 17, 2009 11:59 AM
> To: Bill Mudry
> Cc: php-wind...@lists.php.net
> Subject: Re: [PHP-WIN] Can't seem to transfer a dynamically chosen parameter
> to next page
>
> I haven't looked at your code, but it sounds like you need JavaScript.
> On the page you are going to you will need to pass something. You can
> pass values either through forms or through the URL. URL may be easiest.
>
> If you have a link like http://somehost.com/page_two.php?variable=value
> you can get the variable=value part from the $_GET array. Like this
> $_GET['variable'] will equal 'value'. On your first page you can then
> use JS to set the url for a link to include the value you want to pass.
>
> I don't know how involved the page is, but you can use PHP to generate
> the page and create the links with the variable=value part already on
> them. i.e.
> <a href="http://somehost.com/page_two.php?variable=value">value</a>
> <a href="http://somehost.com/page_two.php?variable=value2">value2</a>
> <a href="http://somehost.com/page_two.php?variable=value3">value3</a>
> <a href="http://somehost.com/page_two.php?variable=value4">value4</a>
>
>
> Cheer,
> James
>
>
> On Tue, 2009-03-17 at 11:39 -0500, Bill Mudry wrote:
> > 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.
> >
> > Bill Mudry
> > MIssissauga, ON
> > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
> --
> James Crow
> IT Manager
> ULTRATAN, Inc.
> <ja...@ultratans.com>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
James Crow
IT Manager
ULTRATAN, Inc.
<ja...@ultratans.com>
--- End Message ---
--- Begin Message ---
Hello
Why would you want to do that with a query string? All form data is
passed on the variables $_POST or $_GET and that is supposed to function
like that.
A query string has a totally different purpose under html...
Cheers
JP
-----Original Message-----
From: Zephaniah ha Levi <zleviti...@fitnessnow.org>
To: 'Bill Mudry' <billmu...@rogers.com>,
Subject: RE: [PHP-WIN] Can't seem to transfer a dynamically chosen
parameter to next page
Date: Tue, 17 Mar 2009 11:54:07 -0400
Why can you not pass the parameter in the url link of the new page using the
get variable?
Example
<form action="welcome.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
When the user clicks the "Submit" button, the URL sent could look something
like this:
http://www.w3schools.com/welcome.php?name=Peter&age=37
The "welcome.php" file can now use the $_GET variable to catch the form data
(notice that the names of the form fields will automatically be the ID keys
in the $_GET array):
Welcome <?php echo $_GET["name"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
-----Original Message-----
From: Bill Mudry [mailto:billmu...@rogers.com]
Sent: Tuesday, March 17, 2009 12:39 PM
To: php-wind...@lists.php.net
Subject: [PHP-WIN] Can't seem to transfer a dynamically chosen parameter to
next page
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.
Bill Mudry
MIssissauga, ON
--- End Message ---
--- Begin Message ---
2009/3/17 Bill Mudry <billmu...@rogers.com>
>
> 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/
--- End Message ---
--- Begin Message ---
Hello Bill
I mixed up names and ended up answering the wrong message. Sorry.
Actually it is quite easy...
In viewallorders.php you should replace:
echo "<a href='showorder.php?$name '>";
with
echo '<a href="showorder.php?&name=' . $name . '">';
and then, in showorder.php
<?php
parse_str($_SERVER['QUERY_STRING'], $qs);
$name = $qs['name'];
and that's it!
Now, the strings passed through this method are insecure. You should use
a parser function to clean or sanitize them (like urlencode/urldecode).
Cheers
JP
-----Original Message-----
From: Bill Mudry <billmu...@rogers.com>
To: php-wind...@lists.php.net
Subject: [PHP-WIN] Can't seem to transfer a dynamically chosen parameter
to next page
Date: Tue, 17 Mar 2009 11:39:08 -0500
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.
Bill Mudry
MIssissauga, ON
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
2009/3/17 Joao Gomes Madeira <jpcg....@gmail.com>:
> Hello Bill
>
> I mixed up names and ended up answering the wrong message. Sorry.
>
> Actually it is quite easy...
>
> In viewallorders.php you should replace:
>
> echo "<a href='showorder.php?$name '>";
>
> with
>
> echo '<a href="showorder.php?&name=' . $name . '">';
>
> and then, in showorder.php
>
> <?php
> parse_str($_SERVER['QUERY_STRING'], $qs);
> $name = $qs['name'];
>
> and that's it!
What have you been smoking? This is already done for you, and the
results are in $_GET. Why duplicate the work?
-Stuart
--
http://stut.net/
> Now, the strings passed through this method are insecure. You should use
> a parser function to clean or sanitize them (like urlencode/urldecode).
>
> Cheers
> JP
>
>
>
>
>
> -----Original Message-----
> From: Bill Mudry <billmu...@rogers.com>
> To: php-wind...@lists.php.net
> Subject: [PHP-WIN] Can't seem to transfer a dynamically chosen parameter
> to next page
> Date: Tue, 17 Mar 2009 11:39:08 -0500
>
> 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.
>
> Bill Mudry
> MIssissauga, ON
> -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
I want to use PHP for command line scripting on Windows. Where would
be the best place to put a class file so that it does not have to be
in the same directory as every file that uses it?
--- End Message ---