473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

POST Method

FF
Hello

I would like send variable to php script from URL
using POST method. Is possible do it ?
( <a href="xxx.php">)
thanks for your help

FF
Jul 17 '05 #1
9 80921
"FF" <fs@dd.pl> a écrit dans le message de news:
d4**********@nemesis.news.tpi.pl...
Hello

I would like send variable to php script from URL
using POST method. Is possible do it ?
( <a href="xxx.php">)
thanks for your help

FF


Hi,
Unfortunately, I dont think it's possible.
Bye
Jul 17 '05 #2
FF wrote:
Hello

I would like send variable to php script from URL
using POST method. Is possible do it ?
( <a href="xxx.php">)


Hi,

I am not sure what you mean, but is this helping?

make URL (with Javascript or whatever)
xxx.php?name=FF&number=42
from xxx.php:

$passedName = $_GET["name"];
$passedNumber = $_GET["number"];

Is that what you want?

Regards,
Erwin Moller

Jul 17 '05 #3
Erwin Moller wrote:
FF wrote:
Hello

I would like send variable to php script from URL
using POST method. Is possible do it ?
( <a href="xxx.php">)


Hi,

I am not sure what you mean, but is this helping?

make URL (with Javascript or whatever)
xxx.php?name=FF&number=42
from xxx.php:

$passedName = $_GET["name"];
$passedNumber = $_GET["number"];

Or alternatively, with POST:

<form action="xxx.php" Method=:post">
<input type="text" name="name">
<input type="text" name="number">
<input type="submit">
</form>

and in xxx.php you retrieve them:

$passedName = $_POST["name"];
$passedNumber = $_POST["number"];
Regards,
Erwin Moller
Jul 17 '05 #4
*** FF wrote/escribió (Fri, 29 Apr 2005 08:37:07 +0200):
I would like send variable to php script from URL
using POST method. Is possible do it ?
( <a href="xxx.php">)


You need an intermediate script so you can:

1) Read the value from $_GET array.
2) Perform an HTTP connecion using the POST method.

Check the curl chapter, it may be helpful.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #5
This has worked in the past for me:

<form action="page.php" method="post" name="myForm">
<input type="hidden" name="name" value="Mr NoName" />
<input type="hidden" name="number" value="52" />
<a href="#" onClick="myForm.submit(); return false;">Click Here</a>
</form>

All the form elements are hidden so it looks like your just clicking a
link, but be careful not to put any sensitive or private information
into the hidden fields as people can still see them when viewing the
page's source

Hope it helps

Jul 17 '05 #6
On 29/04/2005 12:52, co********@gmail.com wrote:
This has worked in the past for me:
Perhaps for a loose definition of "work".

[snip]
<a href="#" onClick="myForm.submit(); return false;">Click Here</a>


If you must refer to a form, do it properly:

document.forms.myForm.submit();

However, the more important concern is of no client-side scripting
support. Navigation should never depend upon a script.

[snip]

The OP should consider if a POST request is really appropriate for the
task at hand. In other words, what's wrong with GET?

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 17 '05 #7
Michael Winter wrote:
If you must refer to a form, do it properly:

document.forms.myForm.submit();

However, the more important concern is of no client-side scripting
support. Navigation should never depend upon a script.


And, if you're going to make absolute statements, you should do *that*
properly. Pedanticism is a 2 way street.

Navigation should never depend on a script where scripting engine
availability and compatibility can't be assured or the exclusion of
clients to whom the scripting functionality will be unavailable causes
undue harm.

Personally, I avoid absolute statements whenever I can, because I know
that my grasp of all possible scenarios is meager at best. And, absolute
statements, particularly those stating "rules" that aren't actually
scientific rules or laws tend to be based on a very specific set of
assumed criteria, which often don't match the questioner's situation.
This results in people following the "rules" to the detriment of their
project because they don't understand the reasoning behind the rules.

For instance, your rule against scripting is based on these assumptions:

1. Publicly accessible site with a "normal" distribution of browsers
including the most recent versions of Mozilla and IE as well as older
versions and more obscure browsers.
2. That a certain number of the viewers will have scripting either
completely incompatible or disabled.
3. That it is a "site" in the first place.

Not all of these things is true for every project. Seriously. I've built
PHP/Javascript applications that aren't accessed through a regular
browser at all. Rather, a customized wrapper around IE is used to launch
the app in fullscreen kiosk mode and is required to send the MAC address
of the ethernet adapter to be allowed into the app. In this case, there
was 100% IE and 100% Javascript compatibility/enabled. I could also
assume 1024x768 as all of the client setups were identical and imaged
from the same disk image. If I'd wasted time avoiding IE-specific
scripting or worked at all on cross-browser setup, I'd have been wasting
my client's money. The project would have suffered for blindly following
the rules.

So, what's the closest thing I use to a rule in regard to these kinds of
solutions? Figure out your userbase and make sure that *they* can use
it, whoever "they" are and quit clinging to absolute rules.

Remember, when someone asks how to do something, they may have a very
different purpose (an entirely reasonable purpose) in mind for the
technology. Just because you can't imagine a scenario that's
appropriate, don't assume one doesn't exist. Use the right tools for the
job.
Jul 17 '05 #8
On 29/04/2005 15:43, J Wynia wrote:
Michael Winter wrote:
[...] the more important concern is of no client-side scripting
support. Navigation should never depend upon a script.
[...] Pedanticism is a 2 way street.


To be pedantic, one must must be debating something irrelevant. I don't
think that challenging a course of action that may be unreliable would
fall under that category.
Navigation should never depend on a script where scripting engine
availability and compatibility can't be assured or the exclusion of
clients to whom the scripting functionality will be unavailable causes
undue harm.
I cannot argue that a statement along these lines would have been
better. However, I feel the important point is that an objection - well
phrased or not - has been raised.

Readers besides the OP may consider the answers in this thread and, even
if the solution is appropriate for the OP, it may not be for others. In
my experience, the misuse of client-side scripting occurs more often
than the avoidance of a scripted solution when it is appropriate.

[snip]
1. Publicly accessible site with a "normal" distribution of browsers
including the most recent versions of Mozilla and IE as well as older
versions and more obscure browsers.
2. That a certain number of the viewers will have scripting either
completely incompatible or disabled.
3. That it is a "site" in the first place.

Not all of these things is true for every project.


I am well aware of that, but I am used to the tendency of the Web being
the norm[1]. Perhaps that is not the case for this group. Are the
assumptions, without any other indication, so unreasonable? If not, and
the OP does have specific requirements or conditions, I would think it
sensible to mention them.

[snip]

Mike
[1] The specific circumstances may be irrelevant for many questions
to this group, but that is not usually the case once focus shifts
client-side.

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

FF wrote:
Hello

I would like send variable to php script from URL
using POST method. Is possible do it ?
( <a href="xxx.php">)
thanks for your help

FF


I have been meaning to write this one...
---------------------------------------

Q. How do I post a form to another site?
A. Use stream_context_create() to create a HTTP POST context, then open
a connection to the site in question with fopen(), passing the context
as the fourth parameter. Use fread() to read the result from the form
submission.

Example:

$post_vars = array(
'post_var1' => "hello",
'post_var2' => "world"
);

// build the request body
foreach($post_vars as $name => $val) {
$pairs[] = $name . '=' . rawurlencode($val);
}
$body = implode("&", $pairs);

// HTTP options
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen($body) . "\r\n" .
"Cookie: foo=bar\r\n",
'content'=>$body
)
);

$context = stream_context_create($opts);

$f = fopen('http://localhost/test.php', 'r', false, $context);
In PHP 5, a context can also be passed to file_get_contents() and
file().

Although stream_context_create() is available since PHP 4.3.0, support
for HTTP POST has only become available in 4.3.5. If you are using an
older version, you would need the cURL functions or use fsockopen() to
open the connection and send the request with fputs().

[cURL example here]

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Spud | last post by:
<?php // pullpage function by Nick bouton http://www.nickbouton.com/. $CustomerID = "IDHERE"; $method = "POST"; $host = "xml.mydata.com"; $usepath = "/xml.asp"; //print all vars in an...
7
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST....
2
by: Asp Help | last post by:
I'm working on a ASP applicatition to create Windows 2000 users. Because I don't want everybody to have access to the site I've changed te security in IIS 5.0 which runs on a windows 2000 Sp4...
2
by: Keith Selbee | last post by:
I am trying to submit data to a webpage in the form of a post and my code is below. It is a function that takes a url and the post content as strings and then performs the post. But as soon as I...
5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
8
by: Kurda Yon | last post by:
Hi, I have to decide which form-method I should use (GET or POST). I found the following recomendation: If the service associated with the processing of a form has side effects (for example,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.