I have the PHP below and it works fine. But this form has room for 2 student numbers and I want to check both.
I tried just duplicating the code below, changing the $stmt1 $stmt2, but I just get my $_SESSION[‘error’] message:
$_SESSION[‘error’] = ‘Step 2.2 Check the SN: This student number: ’ . $studentnr2 . ’ is not in the 20BE classes students’ database. Please try again!’;
Also, $studentnr2 is not displayed. I checked and $studentnr2 is passed to PHP and appears in the text file accompanying the file, and in the text message which PHP writes to a text file.
I also tried calling $pdo $pdo1 and $pdo2, but PHP will not accept that. Is $pdo somehow reserved??
I thought I could call it anything!
Like I said, the code below works fine, and PHP continues and uploads the file I want with the message containing both student numbers, names and email.
How can I integrate the second student number in the checking process??
include '../../includes/studentdbWriteto.inc.php';
//check if the studentnr exists in this course names and numbers list
$stmt1 = $pdo->prepare('SELECT 1 FROM allstudents20BE WHERE studentnr = ?');
try{
$stmt1->execute([$studentnr1]);
//echo 'row count is ' . $stmt1->rowCount();
if($stmt1->rowCount() == 0){
//echo 'this student is not in the database';
$_SESSION['error'] = 'Step 2 Check the SN: This student number: ' . $studentnr1 . ' is not in the 20BE classes students\' database. Please try again!';
//echo $_SESSION['error'];
header('Location: /uploadFiles20BE/uploadessays_pairs_V1.html.php');
exit();
// if the student number exists, carry on, save the answers
}
}
catch(PDOException $e){
$_SESSION['error'] = $e->getMessage();
//echo $_SESSION['error'];
header('Location: /uploadFiles20BE/uploadessays_pairs_V1.html.php');
exit();
}