Accessing Posted Variables
$_POST Documentation
$_POST
is a dictionary which contains all the posted variables. For example, if you posted a name
variable then you can access it like this:
<?php
echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!';
?>
The above example will output something similar to:
Hello Hannes!
Verifying Variables Are Set
isset() Documentation
Sometimes, you might receive invalid requests, so you should do some verification before you try and use the variables, so you don't run some function half way and then error because you weren't passed all the correct variables. You can you isset()
to check if a variable is set. For example:
<?php
if (isset($_POST['name'])) {
echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!';
} else {
echo 'You didn't set the name!';
}
?>
This will output Hello Hannes
if name = Hannes
and You didn't set the name!
if name = null
Advice
Good luck with your project, but it seems like you don't know too much, and as a beginner I would recommend working on something more basic before jumping into webhooks, since they can be quite complex, and it's more beneficial to you, in the long run, to learn the basics first, since you will be able to piece together the more advanced code and learn it easier than just jumping right in.
Sources
http://php.net/manual/en/reserved.variables.post.php
http://php.net/manual/en/function.isset.php