-4

in my server $_GET[] is work but $_POST[] is not work.

i'm use PHP Version 5.3.3 , centos . pleas tell me how to enable Post, always_populate_raw_post_data On post_max_size 200M

ex code where post is not work.

j.php?b=http://stackoverflow.com/questions/ask/gggggggggggggggggggggggggggggggggggg

if use

$_GET["b"] show = http://stackoverflow.com/questi

if use

$_POST["b"] show = (is echo nothing.)

My Real Code is 2 iframe 1 iframe

<IFRAME SRC="http://hi.com/j.php?b=http://stackoverflow.com/posts/21571742/dcfzdczxczxczxczxczxczxczxczxczxczxc" FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="160" HEIGHT="600"></IFRAME>

in these iframe i have no 2 iframe

<IFRAME SRC="http://ad.com/show.php?b='. $_GET["b"] . '&pubclick=[INSERT_CLICK_TAG]" FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="160" HEIGHT="600"></IFRAME>
user3143813
  • 11
  • 1
  • 3

7 Answers7

3

use

<form method="post">
...
</form>

Then it will work.

Gowri
  • 1,832
  • 3
  • 29
  • 53
1

POST is used to get submitted data from a form's input. GET is generally used to get data from url. so to get POST to work, you need to pass values from Form's input fields

Hope this answers your qeustion!!

try this pagewtihlink.php

  <a href="http://localhost:8888/test/next.php?b=1&p=2&ch=&cps=&c=2&l=INh=778f11eb876850b978be52ca49ac4ce8&t=139158‌​8943819">a link</a>

next.php

    <?php

$mylink = $_SERVER['QUERY_STRING'];
echo $mylink;
?>
ashish
  • 3,555
  • 1
  • 20
  • 26
  • i need to get data from url .GET can't echo the full url may its to long so GET can't echo. any other way to gate data from url ???? – user3143813 Feb 05 '14 at 08:17
  • what part of url do you need to echo?? @user3143813 – ashish Feb 05 '14 at 08:22
  • what i load in b url variable. j.php?b=http://stackoverflow.com/posts/21571742/dcfzdczxczxczxczxczxczxczxczxczxczxcxczxczxczxczxczxczxczxczczxczxczxczxczxczxczczxczxczxczxczxczxczxczxczxczxczczxczxczczczczxczczczczc/u= so i need echo http://stackoverflow.com/posts/21571742/dcfzdczxczxczxczxczxczxczxczxczxczxcxczxczxczxczxczxczxczxczczxczxczxczxczxczxczczxczxczxczxczxczxczxczxczxczxczczxczxczczczczxczczczczc/u= – user3143813 Feb 05 '14 at 08:24
  • try this!! $requiredurl = $_GET['b']; echo $requiredurl; – ashish Feb 05 '14 at 08:25
  • check that post on @ghost comment. that might give you some idea – ashish Feb 05 '14 at 08:28
  • actual url is site.com/cr?b=1&p=2&ch=&cps=&c=2&l=INh=778f11eb876850b978be52ca49ac4ce8&t=1391588943819&u= with your $requiredurl echo only site.com/cr?b=1 – user3143813 Feb 05 '14 at 08:31
  • 1
    @ashish GET:Requests data from a specified resource AND POST:Submits data to be processed to a specified resource – ghost Feb 05 '14 at 08:33
  • because there is "&" right after 1 in the requiredurl which will be taken as a new variable. :) – ashish Feb 05 '14 at 08:34
  • oho so how to pass the url with "&" have any way ? – user3143813 Feb 05 '14 at 08:35
0

Try using var_dump($_POST) or print_r($_POST) , and say what output it gives .

Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45
  • i try var_dump($_POST) and print_r($_POST) not work echo nothing – user3143813 Feb 05 '14 at 08:32
  • Hey you are passing GET parameter value via uri in iframe and trying to retrieve the value in $_POST, it wont work my friend."$_POST" is for fetching the value when passed via form submission. in other case you can try $_REQUEST (not recommended). – Dimag Kharab Feb 05 '14 at 09:26
0

Your question just gave me a mild anyorism. But is this what you mean?

$somethingcool = $_POST['somethingcool'];

Also as the others state; make sure you have this in relevant mark-up:

<form method="post"> 
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
0

You are passing variable in querystring so you can fetch this variable using $_GET or $_REQUEST. but if you want to use $_POST then you need to post form data using post method.

Jignesh Patel
  • 1,028
  • 6
  • 10
0

If the data you want to pass is INSIDE the URL, then it will appear in $_GET. There is no way to put it into $_POST in this case.

A browser request will only ever populate $_POST in these cases:

  • a HTML form sent with method "post" and default mimetype application/x-www-form-urlencoded or multipart/form-data.
  • an Ajax request with method "post" and the very same content-type header as the HTML form.

There is no way to send a post if all you have is a link (as in a html href or src attribute). If this leads to a too long URL, the content probably does not want to be included this way, or you should invent a way to shorten it.

Sven
  • 69,403
  • 10
  • 107
  • 109
0

request.php

<a href="http://localhost:8888/test/next.php?b=1&p=2&ch=&cps=&c=2&l=INh=778f11eb876850b978be52ca49ac4ce8&t=139158‌​8943819">a link</a>

result.php

$mylink = $_SERVER['QUERY_STRING'];
echo $mylink;
?>

this worked with me hope it works with you too :) have a nice day!!

ashish
  • 3,555
  • 1
  • 20
  • 26