Jump to content

Need Help! Notice: Undefined variable


voloproductions

Recommended Posts

Hey everyone  I get this error and need to know how to fix it in my code.  I am new to PHP so I am not sure what to do here. 

 

Thanks! 

 

Notice: Undefined variable: mode in C:\wamp\www\iom\log.php on line 12

 

THE ERROR AND OR ISSUE:

Notice: Undefined variable: mode in C:\wamp\www\iom\log.php on line 37

 

MY CODE:

 

<?php 

if(isset($_POST['mode'])) {  
$mode = $_POST['mode']; 
}
if(isset($_GET['mode'])) {
$mode = $_GET['mode'];
}

switch ($mode) {

case 'login':    

$username = $_POST['login'];     
$password = $_POST['password'];


include ('db_fns.php');

	if (!connector())
	{
		die ('connection dies');    
	}

	if (loginCheck($username, $password)) 
	{
		header('location: loggedin.php');
	}

	else 
	{
		die ('login has failed <a href="login.html">Click here to login again</a>'); 
	}

break;

case 'adduser': 

if ($_SESSION['userLevel'] < 2) {
	die('access denied');
}

	$username = $_REQUEST['userName'];  
	$password = $_REQUEST['passWord'];  
	$firstName = $_POST['firstName'];  
	$lastName = $_POST['lastName'];  
	$department = $_POST['department'];  
	$userLevel = $_POST['userLevel'];  


	if (empty($username) || empty($password)){

        echo "please enter a username.";

	die;

	}






	//print_r($_POST); 

	include ('db_fns.php');

	if (!connector())
	{
		die ('connection dies');    
	}

	if(!addUser($username,$password,$firstName,$lastName,$department,$userLevel)) 
	{
		die('There was a problem - contact the system administrator');
	}
	else
	{
		echo "Data has been submitted. <a href=\"/IOM/admin\">return to administration</a>";
	}

	break;

		default:

		break;
				}



?>

Link to comment
https://forums.phpfreaks.com/topic/178081-need-help-notice-undefined-variable/
Share on other sites

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.