ini_set('display_errors', 1); error_reporting(E_ALL); session_name('PONSESSION'); session_start(); $error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $email = strtolower(trim($_POST['email'] ?? '')); if ($email === '') { $error = 'Please enter the email used to post the job.'; } else { // ------------------------------------------------------------------ // Verify job existence by email (Jobs table = source of truth) // ------------------------------------------------------------------ $query = http_build_query([ 'email' => $email ]); $url = "https://www.prooperatornetwork.com/get_jobs.php?$query"; $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 8 ]); $response = curl_exec($ch); $curlError = curl_error($ch); curl_close($ch); if ($curlError || !$response) { $error = 'Connection error. Please try again.'; } else { $data = json_decode($response, true); if (!is_array($data)) { $error = 'System error. Please try again.'; } elseif ( empty($data['success']) || empty($data['records']) || !is_array($data['records']) ) { $error = 'No jobs found for that email address.'; } else { // ---------------------------------------------------------- // Select authoritative Job ID (non-member identity) // ---------------------------------------------------------- $jobRecord = $data['records'][0]; if (empty($jobRecord['id'])) { $error = 'Unable to establish job identity.'; } else { // ------------------------------------------------------ // Establish authoritative non-member session // ------------------------------------------------------ $_SESSION['non_member'] = true; $_SESSION['authenticated'] = true; $_SESSION['ACTIVE_JOB_ID'] = $jobRecord['id']; session_write_close(); header("Location: home-non-operator.php"); exit; } } } } } ?>