The undefined index: q_num for php

Asked by At

I'm creating a quiz website for the term project but when I am referencing my values from php and database, what seems to be problem where there is a notice: undefined index?

I have tried inserting the statement in "if(isset($_POST['q_num']))" but soon, another error arises. the error is in the $q_number = $_POST['q_num']; whereas the error describes "Undefined Index"

$q_number = $_POST['q_num'];

$random = mt_rand(1,44); 
$stmt = $conn->query("SELECT no, question FROM html_ident WHERE no = '$random'");
if($stmt){
    $row = mysqli_fetch_array($stmt);
}

I expect the output to be free from the error "notice: undefined index".

0 Answers