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

POST Params - getting unknown

P: n/a
Hi,

Can anyone tell me if it is possible to generate the actual URL of the
current PHP script (with all POST data included)?

I have a third-party application that I'd like to use to see HTTP
requests to my server. For the most part, it works, but I believe some
of the variables are named incorrectly.

In a nutshell, the application transmits to
http://myserver.com?this=that&that=theOther, where my script grabs the
post data. I want to modify my script to save the actual POST url into
the database so I can see all of the POST parameter names.

Thanks in advance,
- Best regards,
Lee
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Leester" <lr*****@lanl.gov> wrote in message
news:54**************************@posting.google.c om...

Can anyone tell me if it is possible to generate the actual URL of the
current PHP script (with all POST data included)?

I have a third-party application that I'd like to use to see HTTP
requests to my server. For the most part, it works, but I believe some
of the variables are named incorrectly.

In a nutshell, the application transmits to
http://myserver.com?this=that&that=theOther, where my script grabs the
post data. I want to modify my script to save the actual POST url into
the database so I can see all of the POST parameter names.


You *say* 'POST', but you seem to be describing 'GET.'

If I have not misunderstood, something like the following, concatenated
together, should capture what you want:
'http://'
$_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME']
$_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']

You can also look at:
basename(dirname(__FILE__))
basename(__FILE__)
Jul 17 '05 #2

P: n/a

"<>" <lo******@44.255.255.255> wrote in message
news:A7*****************@twister.socal.rr.com...
"Leester" <lr*****@lanl.gov> wrote in message
news:54**************************@posting.google.c om...

Can anyone tell me if it is possible to generate the actual URL of the
current PHP script (with all POST data included)?

I have a third-party application that I'd like to use to see HTTP
requests to my server. For the most part, it works, but I believe some
of the variables are named incorrectly.

In a nutshell, the application transmits to
http://myserver.com?this=that&that=theOther, where my script grabs the
post data. I want to modify my script to save the actual POST url into
the database so I can see all of the POST parameter names.


You *say* 'POST', but you seem to be describing 'GET.'

If I have not misunderstood, something like the following, concatenated
together, should capture what you want:
'http://'
$_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME']
$_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']

You can also look at:
basename(dirname(__FILE__))
basename(__FILE__)


if it is GET and not POST, try looking at these variables:

$_SERVER['HTTPS']
$_SERVER['HTTP_HOST']
$_SERVER['SERVER_PORT']
$_SERVER['REQUEST_URI']

something like this should work ok:

<?php

$url = "http";
if(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) {
$url .= "s";
}
$url .= "://";
$url .= $_SERVER['HTTP_HOST'];
if($_SERVER['SERVER_PORT'] != "80") {
$url .= ":" . $_SERVER['SERVER_PORT'];
}
$url .= $_SERVER['REQUEST_URI'];

?>
Leslie
Jul 17 '05 #3

P: n/a
Leester wrote:
Hi,

Can anyone tell me if it is possible to generate the actual URL of the
current PHP script (with all POST data included)?


POST data is not sent in the URL, it is sent as part of the HTTP request
block. GET data is sent in the URL in the form

http://www.mine.net/page.php?var1=value1&var2=value2

GET should NOT be used for pages that update a database, because then it
is possible for users to unknowingly bookmark that URL, and everytime
that bookmark is clicked, the database will be updated with the same
data that it received the first time.

You could try this on the target page (the script mentioned in action=''
in the <form ...> statement):

foreach($_POST as $varname => $value)
{
echo "<p>\$_POST[$varname] points to $value</p>";
}

I've never tried foreach on $_POST, but it should work.
--
Bob
London, UK
echo Mail fefsensmrrjyaheeoceoq\! | tr "jefroq\!" "@obe.uk"
Jul 17 '05 #4

P: n/a
lr*****@lanl.gov (Leester) wrote in message news:<54**************************@posting.google. com>...
In a nutshell, the application transmits to
http://myserver.com?this=that&that=theOther, where my script grabs the
post data. I want to modify my script to save the actual POST url into
the database so I can see all of the POST parameter names.


If I understand you right....

<?php
$post_vars = '';
if ($_POST)
{
foreach($_POST as $key=>$value)
{
$value = urlencode(stripslashes($value));
$post_vars .= "&$key=$value";
}
$post_vars = substr($post_vars, 1); //remove the first "&" from the
string
}
echo 'POST variables in string: '. $post_vars;
?>

--
"Silence is the only right answer for many wrong questions" --
G.K.Moopanar, Politician
Email: rrjanbiah-at-Y!com
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.