1

I got a javascript for send value to a Popup but only works with $_GET['value'] because when a change to $_POST['value'] it shows this message

Notice: Undefined index: value in C:\wamp\www\corti\presupuestos\precio.php on line 10

this is the javascript code

function envia(){
    var co = $("#codart").val();
    var pag = 'precio.php?value='+co;
    window.open(pag,'Popwin','height=400, width=400');
}

this is the button

<img src="../png/buscar.png" height="16" width="16" onClick="javascript: envia();">

and this is de popup php file

<?php $c=$_POST['value']; echo $c; ?>

thanks for you help and your time

addonisdl
  • 13
  • 6
  • Ah, this question has the answer http://stackoverflow.com/questions/5554896/window-open-post – Popnoodles Oct 31 '13 at 00:24
  • Possible duplicate of [Window.open and pass parameters by post method](http://stackoverflow.com/questions/3951768/window-open-and-pass-parameters-by-post-method) – Ulad Kasach May 18 '16 at 19:33

1 Answers1

1

this is because $_POST can't read url strings query. and you are sending your variable in url string query. that's why you have to use $_GET in your case.

Otherwise, you need to use ajax such as mentioned in many websites articles to perform post. and here's one for example:

http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml

mamdouh alramadan
  • 8,349
  • 6
  • 36
  • 53