Page 1 of 1
Undefined index??
Posted: Wed May 14, 2003 9:44 am
by jiehuang001
Hi, I have a very simple php page abc.php like this:
<?php
$Module_id = $_POST['module_id'];
echo $Module_id;
?>
However, when I type
http://localhost/abc.php?module_id=1,
I got this error:
"Undefined index: module_id in abc.php"
Can someone tell me what is wrong?
Thanks.
Jie Huang
Posted: Wed May 14, 2003 9:47 am
by volka
appending parameters to the url is called GET-method.
PHP stores them in $_GET
http://www.php.net/manual/en/reserved.v ... iables.get
Re: Undefined index??
Posted: Wed May 14, 2003 9:48 am
by Gleeb
jiehuang001 wrote:Hi, I have a very simple php page abc.php like this:
<?php
$Module_id = $_POST['module_id'];
echo $Module_id;
?>
However, when I type
http://localhost/abc.php?module_id=1,
I got this error:
"Undefined index: module_id in abc.php"
Can someone tell me what is wrong?
Thanks.
Jie Huang
$_POST only works on POSTed information. When the information is part of the URL, use $_GET. For example :-
Code: Select all
<?php
$Module_id = $_GET['module_id'];
echo $Module_id;
?>
Posted: Wed May 14, 2003 2:36 pm
by AVATAr
Introduced in php 4.1.0. you can use $_REQUEST['module_id'] if you dont know the method you are using (post or get)...