471,316 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

why doesn't this work?

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
6 1062
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
"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
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
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
"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
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.

Similar topics

39 posts views Thread by Mark Johnson | last post: by
149 posts views Thread by Christopher Benson-Manica | last post: by
4 posts views Thread by bbp | last post: by
3 posts views Thread by Dave Moore | last post: by
10 posts views Thread by Sourcerer | last post: by
6 posts views Thread by Johnny Jörgensen | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.