Forum Moderators: coopster

Message Too Old, No Replies

Undefined index:

         

sirVIPER

7:23 pm on May 7, 2008 (gmt 0)

10+ Year Member



Our website sends automated emails for contacting us when the below form is filled out and is now giving the Undefined index: error. PHP was upgraded to 5.2.5 and now the the email contact information script is no longer working.

<td><?php
/* $_SESSION['Name'] = isSet($_SESSION['Name']) ? $_SESSION['Name'] : ''; // Set default to whatever
$_SESSION['Title'] = isSet($_SESSION['Title']) ? $_SESSION['Title'] : ''; // Set default to whatever
$_SESSION['Company'] = isSet($_SESSION['Company']) ? $_SESSION['Company'] : ''; // Set default to whatever
$_SESSION['Phone'] = isSet($_SESSION['Phone']) ? $_SESSION['Phone'] : ''; // Set default to whatever
$_SESSION['Email'] = isSet($_SESSION['Email']) ? $_SESSION['Email'] : ''; // Set default to whatever
$_SESSION['Network'] = isSet($_SESSION['Network']) ? $_SESSION['Network'] : ''; // Set default to whatever
$_SESSION['Type_of_company'] = isSet($_SESSION['Type_of_company']) ? $_SESSION['Type_of_company'] : ''; // Set default to whatever
$_SESSION['Backup'] = isSet($_SESSION['Backup']) ? $_SESSION['Backup'] : ''; // Set default to whatever
$_SESSION['Platform'] = isSet($_SESSION['Platform']) ? $_SESSION['Platform'] : ''; // Set default to whatever
$_SESSION['Data'] = isSet($_SESSION['Data']) ? $_SESSION['Data'] : ''; // Set default to whatever
//$_SESSION['Name'] = isSet($_SESSION['Name']) ? $_SESSION['Name'] : ''; // Set default to whatever
*/?></td>

Any help will be appreciated.

eelixduppy

7:31 pm on May 7, 2008 (gmt 0)



What is the exact error that you are getting? The undefined index error is probably not what is breaking your script, either. I assume that upon upgrading your php you reset the error reporting level to report notices, and that is why you are getting the undefined index notice. The fact that your email doesn't work anymore might be related to something else. Also, you should note that if the above code is exactly what you have written, it is commented out which may have caused the undefined index errors because then these variables would not have been initialized.

oh, and Welcome to WebmasterWorld! :)

sirVIPER

7:37 pm on May 7, 2008 (gmt 0)

10+ Year Member



<tr>
<td width="30%">&nbsp;</td>
<td><?php
/* $_SESSION['Name'] = isSet($_SESSION['Name']) ? $_SESSION['Name'] : ''; // Set default to whatever
$_SESSION['Title'] = isSet($_SESSION['Title']) ? $_SESSION['Title'] : ''; // Set default to whatever
$_SESSION['Company'] = isSet($_SESSION['Company']) ? $_SESSION['Company'] : ''; // Set default to whatever
$_SESSION['Phone'] = isSet($_SESSION['Phone']) ? $_SESSION['Phone'] : ''; // Set default to whatever
$_SESSION['Email'] = isSet($_SESSION['Email']) ? $_SESSION['Email'] : ''; // Set default to whatever
$_SESSION['Network'] = isSet($_SESSION['Network']) ? $_SESSION['Network'] : ''; // Set default to whatever
$_SESSION['Type_of_company'] = isSet($_SESSION['Type_of_company']) ? $_SESSION['Type_of_company'] : ''; // Set default to whatever
$_SESSION['Backup'] = isSet($_SESSION['Backup']) ? $_SESSION['Backup'] : ''; // Set default to whatever
$_SESSION['Platform'] = isSet($_SESSION['Platform']) ? $_SESSION['Platform'] : ''; // Set default to whatever
$_SESSION['Data'] = isSet($_SESSION['Data']) ? $_SESSION['Data'] : ''; // Set default to whatever
//$_SESSION['Name'] = isSet($_SESSION['Name']) ? $_SESSION['Name'] : ''; // Set default to whatever
*/?></td>
</tr>
<tr>
<td valign="baseline">Name:</td>
<td><label>
<input name="Name_of_respondant" type="text" class="small_blue" id="Name_of_respondant" value="<?php echo "$_SESSION[Name]"; ?>" />
<span class="small_blue">*</span></label></td>
</tr>
<tr>
<td valign="baseline">Title:</td>
<td><input name="Title_of_respondant" type="text" class="small_blue" id="Title_of_respondant" value="<?php echo "$_SESSION[Title]"; ?>" />
<span class="small_blue">*</span></td>
</tr>
<tr>
<td valign="baseline">Company:</td>
<td><input name="Company_of_respondant" type="text" class="small_blue" id="Company_of_respondant" value="<?php echo "$_SESSION[Company]"; ?>" />
<span class="small_blue">*</span></td>
</tr>
<tr>
<td valign="baseline">Phone:</td>
<td><input name="Phone_Number" type="text" class="small_blue" id="Phone_Number" value="<?php echo "$_SESSION[Phone]"; ?>" maxlength="15" />
<span class="small_blue">*</span></td>
</tr>
<tr>
<td valign="baseline">Email:</td>
<td><input name="Email_Address" type="text" class="small_blue" id="Email_Address" value="<?php echo "$_SESSION[Email]"; ?>" />
<span class="small_blue">*</span></td>
</tr>
<tr>
<td valign="baseline">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="baseline">Number of people on network:</td>
<td><input name="Number_of_people_on_computer_network" type="text" class="small_blue" id="Number_of_people_on_computer_network" value="<?php echo "$_SESSION[Network]"; ?>" />

I did not post enough sorry about that the errors are below.

PHP Notice: Undefined index: Name in E:\WEB SITE\One Safe Place\contact\index.php on line 191
PHP Notice: Undefined index: Title in E:\WEB SITE\One Safe Place\contact\index.php on line 196
PHP Notice: Undefined index: Company in E:\WEB SITE\One Safe Place\contact\index.php on line 201

Line 191 is the first line that matches the following:

<span class="small_blue">*</span></label></td>

[edited by: jatar_k at 10:46 pm (utc) on May 7, 2008]
[edit reason] trimmed code dump [/edit]

eelixduppy

7:55 pm on May 7, 2008 (gmt 0)



It is as I expected, I'm pretty sure. You have to remove the code as a comment at the top because they aren't being initialized to anything. It should look like the following:

<td><?php
$_SESSION['Name'] = isSet($_SESSION['Name']) ? $_SESSION['Name'] : ''; // Set default to whatever
$_SESSION['Title'] = isSet($_SESSION['Title']) ? $_SESSION['Title'] : ''; // Set default to whatever
$_SESSION['Company'] = isSet($_SESSION['Company']) ? $_SESSION['Company'] : ''; // Set default to whatever
$_SESSION['Phone'] = isSet($_SESSION['Phone']) ? $_SESSION['Phone'] : ''; // Set default to whatever
$_SESSION['Email'] = isSet($_SESSION['Email']) ? $_SESSION['Email'] : ''; // Set default to whatever
$_SESSION['Network'] = isSet($_SESSION['Network']) ? $_SESSION['Network'] : ''; // Set default to whatever
$_SESSION['Type_of_company'] = isSet($_SESSION['Type_of_company']) ? $_SESSION['Type_of_company'] : ''; // Set default to whatever
$_SESSION['Backup'] = isSet($_SESSION['Backup']) ? $_SESSION['Backup'] : ''; // Set default to whatever
$_SESSION['Platform'] = isSet($_SESSION['Platform']) ? $_SESSION['Platform'] : ''; // Set default to whatever
$_SESSION['Data'] = isSet($_SESSION['Data']) ? $_SESSION['Data'] : ''; // Set default to whatever
//$_SESSION['Name'] = isSet($_SESSION['Name']) ? $_SESSION['Name'] : ''; // Set default to whatever
?></td>