Receiving 'undefined index:name' error using php

  • Profile Image
    Asked on July 07, 2015 at 05:15 AM

    I have used the code above and got errors that 'undefined index:name'. How do i correct that error and why does it bring that error?

    This is a re-post of a comment on How to send Submissions to Your MySQL Database Using PHP

  • Profile Image
    Answered on July 07, 2015 at 05:43 AM

    Please note that your variables must match what you are passing. It sounds like you may be trying to set the $name variable in your PHP, but you are not passing it within the POST Data.

    You may want to try changing your $name line from:

    $name = $_POST['name'];


    if(isset($_POST['name'])){ $name = $_POST['name']; }

    Please try and make sure that all the variables that you are using match, so that you are actually passing the name variable before trying to use it. If you continue to experience the issues after using the ISSET command to set the variable, please let us know which form is having this problem (so that we can check it out), as well as please post your entire PHP script that you are using. You can paste it on Pastebin or a similar service if the script is very long.

    I hope this helps.

  • Profile Image
    Answered on June 16, 2016 at 11:15 PM

    Good One from the author..thanks mate!!!

    Please visit my article on PHP undefined index..

  • Profile Image
    Aleksandar Krzavac 
    Answered on August 13, 2016 at 12:22 PM

    Although I followed your instruction putting ISSET command to set variables I still have notice 

    Parse error: syntax error, unexpected 'shipping_city' (T_STRING), expecting ']' in C:\wamp64\www\shopping\purchase.php on line 64

    Please let me know what to do.

    I look forward to your response.

    Best Regards,


    Aleksandar Krzavac

  • Profile Image
    Answered on August 13, 2016 at 02:52 PM

    To give you a better answer and not get confused with the current thread. I have created a new thread that will be answered shortly.


  • Profile Image
    chandan kumar  
    Answered on July 12, 2017 at 09:31 PM

    very very bad positng for me i am scare too much