当前位置: 动力学知识库 > 问答 > 编程问答 >

PHP. Get data send with <form action="url.php?var=DATA"></form>

问题描述:

How to get a value of the $_GET?

E.G

How to get number 14 from action="doSomething.php?OrderNumber=14"

I know how to check if the orderNumber === "14", but I need to get this value and use it somewhere else.

Any suggestion much appreciated.

网友答案:

You can use $_GET['OrderNumber'] or $_REQUEST['OrderNumber']

网友答案:

The same as you would normally retrieve a GET variable:

$orderNumber = $_GET['orderNumber']; //Stores 14

You can find more information about $_GET here.

网友答案:

$_GET['var'] should be populated in url.php after form is submitted, $_GET['OrderNumber'] should be populated in doSomething.php after form is submitted, if this is not the answer, please elaborate.

网友答案:

If you dump $_GET using print_r for instance, you will notice that it is actually an key/value array. So if you want to get OrderNumber, you just have to use:

<?php
$order = (int)$_GET['OrderNumber']; #to unsure ordernumber is a number
// use $order anywhere you want
save($order); // for instance

in the file doSomething.php.

分享给朋友:
您可能感兴趣的文章:
随机阅读: