$_REQUEST[] or $_POST[] Undefined array key error [duplicate]

I have a PHP script that gets two parameters from an AJAX script on another page, but it gets an error on each $_REQUEST[], gets the same error if using $_POST[]

Undefined array key “visitor” in /home/tltl2347/public_html/pagevisited.php on line 7

Undefined array key “pagename” in /home/tltl2347/public_html/pagevisited.php on line 8

Here is the script

<?php

    date_default_timezone_set('Australia/Perth');
    $today = date('Y-m-d H:i:s');
    $logdata = "rn";

    $userAnswer = $_REQUEST['visitor'];
    $pageName = $_REQUEST['pagename'];
    $visitorip = $_SERVER['REMOTE_ADDR'];

    $visitor =  $userAnswer;
    $pagename = $pageName;
    $output = $today . "," . $visitor . "," . $pagename . "," . $visitorip . $logdata;

    if(($visitor !== 'JAMES BOND')) // Avoid registring myself
    {
       if($visitor !== "")
       {
         $file = fopen("pagevisit.csv","a");
         fwrite($file,$output);
         fclose($file);
       }
    }
?>

But the line:

$output = $today . "," . $visitor . "," . $pagename . "," . $visitorip . $logdata;

Is executed down correctly

Is there a way for me to hold on until $visitor and $pagename are taken?