Undefined index errors on contact formRSS

4 replies

Last post Oct 31, 2018 11:08 PM by Derly Pacheco

  • Undefined index errors on contact form

    Aug 13, 2009 11:27 AM|mthakershi|LINK


    I just moved my website to IIS 7 running PHP. I installed it using web component installer.

    Static PHP pages seem to run fine. But I have a contact form that throws errors.

    Errors are:

    PHP Notice: Undefined index: contact_lastname in C:\inetpub\wwwroot\contact.php on line 34 PHP Notice: Undefined index: contact_firstname in C:\inetpub\wwwroot\contact.php on line 35 PHP Notice: Undefined index: contact_email in C:\inetpub\wwwroot\contact.php on line 36 PHP Notice: Undefined index: contact_phone in C:\inetpub\wwwroot\contact.php on line 37 PHP Notice: Undefined index: contact_department in C:\inetpub\wwwroot\contact.php on line 38 PHP Notice: Undefined index: contact_description in C:\inetpub\wwwroot\contact.php on line 39

    Here is the code that is causing errors:

                        <form name="contactform" method="post" action="sent.php">
                            <input type="hidden" name="create" value="contact">
                            First Name:<sup>*</sup><input type="text" name="contact_firstname" value="<?php echo $_POST['contact_lastname']?>"><br />
                            Last Name:<sup>*</sup><input type="text" name="contact_lastname" value="<?php echo $_POST['contact_firstname']?>"><br /><br />
                            E-Mail:<sup>*</sup><input type="text" name="contact_email" value="<?php echo $_POST['contact_email']?>"><br />
                            Phone:<sup>*</sup><input type="text" name="contact_phone" value="<?php echo $_POST['contact_phone']?>"><br />
                            Organization:<sup>*</sup><input type="text" name="contact_department" value="<?php echo $_POST['contact_department']?>"><br /><br />
                            Comments:<textarea name="contact_description"><?php echo $_POST['contact_description']?></textarea><br />
                            <input type="button" value="Submit" class="click" onClick="ValidateForm();"><br />

    Any help is appreciated.

    I checked under IIS 7 FastCGI settings that all verbs are allowed.


  • Re: Undefined index errors on contact form

    Aug 13, 2009 03:20 PM|mthakershi|LINK

    Fixed by inserting

    error_reporting(E_ALL & ~E_NOTICE);

    in my PHP code.

  • Re: Undefined index errors on contact form

    Aug 15, 2009 01:55 PM|pierrejoye|LINK

     To hide a message does not fix the source of the error.

     You should check the index before you use:

     if (isset($ar['somekey'])) ...

  • Re: Undefined index errors on contact form

    Jan 10, 2012 10:43 AM|agilb884|LINK

    I had a similar problem. I was able to get my php scripts to work from a web app in IIS 7.0 but not when running the same site from the Expression Web Development Server. The problem was the way I had set up PHP in my Expression Web Dev Server. I was pointing at the wrong php executable. Originally I had set the server up to use "php-win.exe". When I changed it to use "php-cgi.exe" my undefined index problem was resolved. I am using version: php-5.4.0RC4-Win32-VC9-x86 on a 32 bit Windows Vista laptop (Service Pack 2). Lastly, I recommend wrapping your code in an if block that tests for the availability of the indices you are accessing. The following is a snippet I "borrowed" off of another post. In my case, 'fname' is the name of the array index I am accessing. if(isset($_POST) && array_key_exists('fname',$_POST)) Bottom line, this may be a configuration issue and have nothing to do with your code.
  • Re: Undefined index errors on contact form

    Oct 31, 2018 11:08 PM|Derly Pacheco|LINK


    in my case is the line 460 

    of the file php.ini

    i'm sorry for my english