By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,464 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,464 IT Pros & Developers. It's quick & easy.

why doesn't this work?

P: n/a
All I'm trying to do is pass a value to a page from a link. First, here
is the page with the link.
<HTML>
<HEAD></HEAD>
<BODY>
<FORM action=receivePost.php method=POST>
<a href="receivePost.php?abc=snazzi&def=flattened">cl ick for amazing
results and happiness at least through the weekend.</a>
<BR><BR><input type=text name=def>
<BR><BR><input type=submit value='push me'>
</FORM>
</BODY>
</HTML>

If you want to copy the above page, name it sendPost.htm

Next, the page that receives and *SHOULD* display the results. Either
it's not receiving or it's not displaying. Either way, I cannot get a
value for abc. The text box is there just to see if I could pass data
the way that I have experience with.

<?php
echo "<HTML>";
echo "<HEAD></HEAD>";
echo "<BODY>";
echo "abc is $_POST[abc]";
echo "<BR>def is $_POST[def]";
echo "<BR><BR><a href='sendPost.htm'>go back</a>";
echo "</BODY>";
echo "</HTML>";
?>

this file should be named receivePost.php

Thank you in advance, o learned and generous and patient lot that thou art.
Jeff Sandler
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Lee
Jeff Sandler said:

All I'm trying to do is pass a value to a page from a link. First, here
is the page with the link.
<HTML>
<HEAD></HEAD>
<BODY>
<FORM action=receivePost.php method=POST>
<a href="receivePost.php?abc=snazzi&def=flattened">cl ick for amazing
results and happiness at least through the weekend.</a>
<BR><BR><input type=text name=def>
<BR><BR><input type=submit value='push me'>
</FORM>
</BODY>
</HTML>

If you want to copy the above page, name it sendPost.htm

Next, the page that receives and *SHOULD* display the results. Either
it's not receiving or it's not displaying. Either way, I cannot get a
value for abc. The text box is there just to see if I could pass data
the way that I have experience with.

<?php
echo "<HTML>";
echo "<HEAD></HEAD>";
echo "<BODY>";
echo "abc is $_POST[abc]";
echo "<BR>def is $_POST[def]";
echo "<BR><BR><a href='sendPost.htm'>go back</a>";
echo "</BODY>";
echo "</HTML>";
?>

this file should be named receivePost.php

Thank you in advance, o learned and generous and patient lot that thou art.


You'll find that we're actually more patient with questions that have anything
at all to do with Javascript. You seem to have a PHP question.

Jul 23 '05 #2

P: n/a
"Jeff Sandler" <ff*******@dslextreme.com> skrev i meddelandet
news:10*************@corp.supernews.com...
All I'm trying to do is pass a value to a page from a link. First, here
is the page with the link. <snip>
Next, the page that receives and *SHOULD* display the results. Either <snip> <?php
echo "<HTML>";
echo "<HEAD></HEAD>";
echo "<BODY>";
echo "abc is $_POST[abc]";


echo 'abc is ' . $_POST['abc'];

Assuming that you get to the PHP page all right, you then need to 1) use the
concatenation operator ".", 2) quote the array index into $_POST. (At least,
the way I'm used to PHP)

Joakim Braun
Jul 23 '05 #3

P: n/a
Thank you for your suggestions. The bad news is I tried them and it
still doesn't work. I await your reply.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4

P: n/a
In article <10*************@corp.supernews.com>,
ff*******@dslextreme.com says...
All I'm trying to do is pass a value to a page from a link. First, here
is the page with the link.


<snip>

Where's the JavaScript?

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #5

P: n/a
"Jeff Sandler" <ff*******@dslextreme.com> wrote in message
news:10*************@corp.supernews.com...
All I'm trying to do is pass a value to a page from a link. First, here is the page with the link.
<HTML>
<HEAD></HEAD>
<BODY>
<FORM action=receivePost.php method=POST>
<a href="receivePost.php?abc=snazzi&def=flattened">cl ick for amazing
results and happiness at least through the weekend.</a>
<BR><BR><input type=text name=def>
<BR><BR><input type=submit value='push me'>
</FORM>
</BODY>
</HTML>

If you want to copy the above page, name it sendPost.htm

Next, the page that receives and *SHOULD* display the results. Either
it's not receiving or it's not displaying. Either way, I cannot get a
value for abc. The text box is there just to see if I could pass data
the way that I have experience with.


-abc- is not going to be passed to -receivePost.php- if the -submit-
button is being clicked (it is not part of the form).

-abc- will be passed to -receivePost.php- if you click the hypertext
link, but it won't be part of a POST, it will be the result of a GET.

To retrieve the value of -abc- in <a
href="receivePost.php?abc=snazzi&def=flattened"> you need to retrieve

$_GET['abc']

not

$_POST['abc']

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #6

P: n/a
On 23 Dec 2004 10:55:35 -0600, Jeff Sandler <ff*******@dslextreme.com>
wrote:
Thank you for your suggestions. The bad news is I tried them and it
still doesn't work. I await your reply.


As Lee implied, you'd find more help at a PHP group like comp.lang.php.

However, I can tell you that you should be using $_GET not $_POST, and you
should be able to improve performance by only writing the dynamic parts:

<?php
if(count($_GET)) {
echo "\t<dl>\n";
foreach ($_GET as $key => $value) {
echo "\t<dt>$key</dt><dd>$value</dd>\n";
}
echo "\t</dl>\n";
} else {
echo "<p>No name/value pairs were sent to this page.</p>\n";
}
?>

A full example (in plain text) can be found at
<URL:http://www.mlwinter.pwp.blueyonder.co.uk/clj/sandler/get.php.txt>.

Good luck,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.