I'm trying to send an array with its values from the first page to the second page. On the second page what I want to happen is that it the sent array values will be transferred to a new array. Here's my current progress:
Snippet code of
Report_Status.php(First Page / Source, where the array with values is initailized)
$message = array(
'title' => 'Report Approved!',
'body' => 'Thank you for reporting! We already approved/verified your report as a legit fire incident. Wait for the firefighters to arrive.'
);
while ($User_Row = mysqli_fetch_array($Retrieve_User, MYSQLI_ASSOC)){
$User_Token[] = $User_Row['User_Token'];
}
send_notification($User_Token, $message); //calling a function of the second page.
//I will replace the it from calling a function to redirecting to a specific web link
This first page retrieves a specific data (which is the user's token) from the database and stores it into an array (
$User_Token[]). Initialization.Snippet code of
Push_User_Notification.php(Second page / Destination, where the array with its values will be received.
//Here: there should be the code for catching/receving the array
$Retrieve_Target_Tokens_Query = "SELECT * FROM User WHERE User_Token = $tokens";
$Retrieve_Target_Tokens = mysqli_query($Connection, $Retrieve_Target_Tokens_Query);
$tokens = array();
if(!$Retrieve_Target_Tokens){
echo "<script type = 'text/javascript'> alert('Server Error: Could retrieve tokens from database because of this error: ". mysqli_error($Connection)."') </script>";
}
if(mysqli_num_rows($Retrieve_Target_Tokens) > 0){
while($Token = mysqli_fetch_array($Retrieve_Target_Tokens)){
$tokens[] = $Token['User_Token'];
}
}
$message = array("message" => "Your Report has been approved by an admin! Please wait for firefighter/s to arrive.");
send_notification($tokens, $message);
function send_notification ($tokens, $message)
{
//Process of Firebase sending notification here (No problem on this function)
}
Question:
- How can i send an array from a one page and receive it successfully to another page?
P.S. This code/s sends a push notification to specific android users only.