Please Php error Notice: Undefined index: type in [Closed]

mohamedphoneact 1 Posts Sunday September 23, 2018Registration date September 23, 2018 Last seen - Sep 23, 2018 at 10:07 AM - Latest reply: Ambucias 55490 Posts Monday February 1, 2010Registration dateModeratorStatus October 14, 2018 Last seen
- Sep 23, 2018 at 05:03 PM
hello
i have an error that persists when i try to move to a page assign this is the capture of the error if you can help me solve the problem.




<?php
require_once '../library/config.php';
require_once '../library/functions.php';

checkUser();

$action = isset($_GET['action']) ? $_GET['action'] : '';

switch ($action) {
	
	case 'add' :
		assignUser();
		break;
		
	case 'delete' :
		deleteUser();
		break;

	default :
	    // if action is not defined or unknown
		// move to main user page
		header('Location: index.php');
}


/*
functaion is used to assign Hardware, software to user, lab.
if the given qualtity is greater then available quantity then it shows error message to user.
*/
function assignUser()
{
	$entity = $_POST['entity'];
	$type = $_POST['type'];
	$qty = (int)$_POST['txtQty'];
	$dop = $_POST['txtDp'];
	$dor = $_POST['txtDr'];
	$uid = $_POST['txtUid'];
	
	
	$hsql = "SELECT avbl_qty AS avbl 
	        FROM tbl_hardwares
			WHERE id = $type";
	$ssql = "";
	
	if($entity == 1){
		$res = dbQuery($hsql);
		$avbl_qty;
		while($row = dbFetchAssoc($res)){
			$avbl_qty = $row['avbl'];
			
		}//while
		if($avbl_qty < $qty) {
			header('Location: ../view.php?v=assign&error=' . urlencode('Hardware Quantity is more then available Quantity. Please add less.'));	
		}else {
			//update avbl_qty
			$sql = "UPDATE tbl_hardwares 
					SET avbl_qty = avbl_qty - $qty 
					WHERE id = $type";
			//dbQuery($sql);
			$sql = "INSERT INTO tbl_assignments (entity, type, qty, uid, doa, doe, bdate)
					VALUES($entity, $type, $qty, $uid, '$dop', '$dor', NOW() )";
			dbQuery($sql);
			header('Location: ../assign');				
		}//else
	}else {
		//echo "SW";
		$sql = "INSERT INTO tbl_assignments (entity, type, qty, uid, doa, doe, bdate)
					VALUES($entity, $type, $qty, $uid, '$dop', '$dor', NOW() )";
			dbQuery($sql);
		header('Location: ../assign');				
	}
}

?>
See more 

1 reply

Ambucias 55490 Posts Monday February 1, 2010Registration dateModeratorStatus October 14, 2018 Last seen - Sep 23, 2018 at 05:03 PM
0
Thank you
Greetings,

Please, bare in mind that CCM.net is a mutual aid community, all answers on the forum are provided by volunteers who give their time free to help solve issues.

Hence we request that CCM forum users show mutual respect. Therefore, when asking for assistance, please be courteous, as for elsewhere in similar circumstances in every day society when asking for help. (Usually, how would someone ask for help? i.e. please, thank you, appreciate, grateful, etc.)

Being courteous will increase your chances of getting the help you need.

http://ccm.net/contents/948-terms-of-use-for-ccm-respect-for-others

Please, copy, modify and repost your message respecting the politeness charter.

We trust that you understand.

Moderator