So this is one of the most common questions i see people post throughout forums. Hopefully it will be made as a sticky topic on this forum because i think its well needed. Anyways heres a few different methods for writing your post/get request without getting an undefined index error.
Checks to be sure the post array isset before actually attempting to get the value
if it isset we get the value otherwise we return a default value of false
$name = (isset($_POST['name'])) ? $_POST['name'] : false;
Method 3 (see replies, below)
Create a function to handle the post request and to be sure it isset
//Create a post request to get a form field value that has a name of name
$name = post('name');
so anyways these are just a few methods. Hope it helps people not to have to ask this question so often.
//Declare the variable before trying to do a post request
$name = "";
$name = $_POST['name'];