<?php
    include "connection.php";
     if(!isset($_SESSION)) 
        { 
            session_start(); 
        } 
    $cand1  = $_POST['cand1'];
    $cand2  = $_POST['vice1'];
    $sess   =  $_SESSION['SESS_NAME'];
    if(!$cand1){
    $error="<center><h4><font color='#FF0000'>Please fill empty fields</h4></center></font>";
    include"student.php";
    exit();
    }
        $cand1 = addslashes($cand1);
        $cand1 = mysqli_real_escape_string($con,$cand1);
    $sql = 'SELECT * FROM student WHERE username="'.$_SESSION['SESS_NAME'].'" AND status="VOTED"';
    $result = mysqli_query($con,$sql);
                if (mysqli_num_rows($result)==1){
            $msg="<center><h4><font color='#FF0000'>You have already been voted, No need to vote again</h4></center></font>";
            include 'student.php';
            exit(); 
                }
                else{
                 $sql = 'UPDATE candidate SET votecount = votecount + 1 WHERE cand_id = "'.$_POST['cand1'].'" OR cand_id = "'.$_POST['vice1'].'"';
                $sql2 = 'UPDATE student SET status="VOTED" WHERE username="'.$_SESSION['SESS_NAME'].'"';
                $result = mysqli_query($con,$sql);
                $result2 = mysqli_query($con,$sql2);
        if(!$result && !$result2){
        die("Error on mysql query".mysqli_error());
        }
        else{
        $msg="<center><h4><font color='#FF0000'>Congratulation, you have made your vote.</h4></center></font>";
        include 'student.php';
        exit();
        }
                }
    ?>
the errors are at code including $sess= $_SESSION['SESS_NAME']; and at username="'.$_SESSION['SESS_NAME'].'" i have tried every possibility so can you check my code? mainly the error is undefined index at $session[session_name]?
 
     
    