Jump to content

Undefined index: $_GET and !isset


new_born191285

Recommended Posts

Hi all,

I have 2 undefined index errors which I don't know hot to solve (I am new to PHP) :quiet: I would appreciate it if anyone can help solve these 2 errors;

 

[Notice: Undefined index: mode in /var/www/html/phpTrafficA-2.0.1/index.php on line 54

 

Notice: Undefined index: mode in /var/www/html/phpTrafficA-2.0.1/index.php on line 56

 

<?php
if (!isset($mode) or $mode == "") {
$mode = 
$_GET["mode"];
if ($mode == "") { $mode = 
$_POST["mode"];}
?>

 

I'm running php 5.2.6 and have register_globals on if that helps :)

 

Cheers,

Link to comment
https://forums.phpfreaks.com/topic/120496-undefined-index-_get-and-isset/
Share on other sites

Use something like:

<?php
if (isset($_GET['mode'])) $mode = $_GET['mode'];
if (!isset($mode) && isset($_POST['mode'])) $mode = $_POST['mode'];
if (!isset($mode)) $mode = 'Error';
?>

 

And TURN OFF REGISTER GLOBALS (Yes, I'm shouting)

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.