Results 1 to 3 of 3

Thread: How To: Get rid of undefined index errors

Threaded View

  1. #1
    Join Date
    Aug 2011

    How To: Get rid of undefined index errors

    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.

    Method 1
    PHP Code:
    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 2
    PHP Code:
    Create a function to handle the post request and to be sure it isset
    function post($post){
    //Create a post request to get a form field value that has a name of name
    $name post('name');
    Method 3 (see replies, below)
    //Declare the variable before trying to do a post request
    $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.
    Last edited by NogDog; 01-31-2013 at 12:53 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles