3 Replies - 513 Views - Last Post: 27 June 2013 - 06:23 AM

#1 poliosynthesis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 27-June 13

Undefined index, very vague. Sorry If I'm being sped

Posted 27 June 2013 - 02:56 AM



$ids = ($_REQUEST['ids']);





I have used every variation on "ids" in my code. What am I doing wrong. I have reread my code several times and have no idea what I've done wrong.
Notice: Undefined index: IDs in C:\php work\xampp\htdocs\TestSite\delete1.php on line 6
Is This A Good Question/Topic? 0
  • +

Replies To: Undefined index, very vague. Sorry If I'm being sped

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Undefined index, very vague. Sorry If I'm being sped

Posted 27 June 2013 - 03:00 AM

is this form submitting to itself? have you named the input fields?

otherwise: var_dump($_REQUEST);
Was This Post Helpful? 0
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Undefined index, very vague. Sorry If I'm being sped

Posted 27 June 2013 - 03:14 AM

I can think of three things you are doing wrong there.

First, you are apparently fetching this request variable without making sure it exists. Always make sure user input is present before using it. See the empty and isset functions for that.

Second, you are copying the unaltered user input into a global variable. Why? As a general rule, don't move user input out of the request super-globals unless you've verified and sanitized (if needed) the values first. Keep the raw user input in the super-globals.

Third, you are using the $_REQUEST super-global. In 99% of cases, you will know before hand where the user input is coming from. (And you want to avoid that 1% of cases like the plague!)

The $_REQUEST array contains values from up to five different sources: the query string ($_GET), the post data ($_POST), the cookies ($_COOKIE), the server values ($_SERVER) or the environmental values ($_ENV). Using the proper super-global, matching the known source, can spare you some hard to debug issues. Like if you happen to use the same key for a GET and POST value, the GET value will override the POST value by default.

So, if you are expecting a GET value, use $_GET; if you are expecting a POST value, use $_POST; and so forth.
Was This Post Helpful? 2
  • +
  • -

#4 poliosynthesis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 27-June 13

Re: Undefined index, very vague. Sorry If I'm being sped

Posted 27 June 2013 - 06:23 AM

Thanks very much guys, will go over it again :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1