Undefined Index Warning

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fullfocus
Forum Commoner
Posts: 33
Joined: Fri Jun 30, 2006 2:51 pm

Undefined Index Warning

Post by fullfocus »

Hello:

I'm running a script which is resulting with one variable as an Undefined Index. The error message is:
Undefined index: intcredit in C:\Inetpub\fullfocus\AtlantaMtgPlace\loan_options.php on line 23

I do not understand why this message is appearing. The form which contains the answer to this question is a radio button. I have two additional radio button questions right above it and their values are coming through to the script without a problem. For some reason, my script doesn't like the variable "intcredit".

Can someone help me out? I copied and pasted one of the other radio buttons and modified it for this variable.

This is the script which contains the form.

Code: Select all

<?php

include('header.html');


require_once ('mysql_connect.php');

if (isset($_POST['submitted'])) {
  $errors = array();

  //validate form data  
  if (empty($_POST['downpmt'])) {
    $errors[] = 'Please enter a down payment.';
   } else {
    $_SESSION['downpmt'] = escape_data($_POST['downpmt']);
   }
}

$_SESSION['loan_amount'] = 0;
$_SESSION['cltv'] = 0;
$_SESSION['ltv'] = 0;

$_SESSION['loan_amount'] = $_SESSION['purchaseprice'] - $_SESSION['downpmt']; 
$_SESSION['cltv'] = $_SESSION['loan_amount'] / $_SESSION['purchaseprice'];
$_SESSION['ltv'] = $_SESSION['cltv'];

?>
<p><b>Your Information:</b></p>
<table>

<tr><td><b>Purchase Price:</b></td><td>&nbsp;&nbsp;</td><td><?php echo number_format($_SESSION['purchaseprice'],2); ?></td></tr>
<tr><td><b>Planned Closing Date:</b></td><td>&nbsp;&nbsp;</td><td><?php echo $_SESSION['date']; ?></td></tr>
<tr><td><b>Location:</b></td><td>&nbsp;&nbsp;</td><td><?php echo $_SESSION['location']; ?></td></tr>
<tr><td><b>Down Payment:</b></td><td>&nbsp;&nbsp;</td><td><?php echo number_format($_SESSION['downpmt'],2); ?></td></tr>
<tr><td><b>Loan Amount:</b></td><td>&nbsp;&nbsp;</td><td><?php echo number_format($_SESSION['loan_amount'],2); ?></td></tr>
<tr><td><b>CLTV:</b></td><td>&nbsp;&nbsp;</td><td><?php echo number_format($_SESSION['cltv'] * 100,2); ?>%</td></tr>
<tr><td><b>LTV:</b></td><td>&nbsp;&nbsp;</td><td><?php echo number_format($_SESSION['ltv'] * 100,2); ?>%</td></tr>
</table>
<hr>
<p>Please answer the following questions to see your loan options.</p>

<form name="my_form" id="my_form" action="searchrates.php" method="post">

<p><label for="propuse">Property use:</label>
<select name="propuse" size="1""> 
    <option value="Home">as a Home</option></SELECT></p>

<p><label for="proptype">Property type:</label>
<select name=proptype>
   <option value="Single Family">Single Family Residence</option>
   <option value="Condo">Condominium-less than 4 stories</option></select></p>

<p><label for="bincome">Borrower<br>Gross Monthly Income (before taxes):</label> <input type="text" name="bincome" size="15" maxlength="15" /></p>
<p>&nbsp;</p>
<p><label for="cincome">Co-Borrower<br>Gross Monthly Income (before taxes):</label> <input type="text" name="cincome" size="15" maxlength="15" /></p>
<p>&nbsp;</p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td><b>Credit History:</b>&nbsp;&nbsp;</td>
	<td>
	<select name="fico">
        <option value=""></option>
        <option value=720>Excellent&nbsp;&nbsp;(over 720) </option>
	<option value=700>Very Good&nbsp;&nbsp;(700-719)</option>
	<option value=680>Good&nbsp;&nbsp;(680-699)</option>
        <option value=620>Fair&nbsp;&nbsp;(620-679)</option>
	<option value=619>Poor&nbsp;&nbsp;(below 619)</option>
	</select>
	</td>
	<td width=25><b>&nbsp;&nbsp;&nbsp;OR</b></td><td>&nbsp;&nbsp;</td>
	<td><b>Approximate credit score:</b>&nbsp;&nbsp;</td>
	<td><input type=text name=ficonum size=3 maxlength=3 value=""></td></tr>
	
	</table>
  <p>&nbsp;</p>
<tr><td colspan=2><p style="line-height: 20px;"><b>Are you willing to document your income during the loan process?</b><br>
	<INPUT TYPE=RADIO name=docincome VALUE=Yes checked>&nbsp;<b>I will document</b> my income for the lender.<BR>
   	<INPUT TYPE=RADIO name=docincome VALUE=No >&nbsp;<b>I will not document</b> my income.  I understand stated loans are subject to higher interest
         rates.</p></td></tr>  
<tr><td colspan=2><p style="line-height: 20px;"><b>Do you plan to escrow?</b><br>
	<INPUT TYPE=RADIO NAME=escrow VALUE=Yes checked>&nbsp;Yes, I will escrow.<BR>
   	<INPUT TYPE=RADIO NAME=escrow VALUE=No >&nbsp;No, I will not escrow.</p></td></tr>

[COLOR="Red"]<tr><td colspan=2><p style="line-height: 20px;"><b>If closing on or before the 5th of the month, do you want an interest credit? (First mortgage payment will be at the beginning of the next month.  Ex: closing date is 6/5/2007, first payment is on 7/1/2007)</b><br>
	<INPUT TYPE=RADIO NAME=intcredit VALUE=Yes checked>&nbsp;Yes, I want an interest credit.<BR>
   	<INPUT TYPE=RADIO NAME=intcredit VALUE=No >&nbsp;No, I do not want an interest credit.</p></td></tr>[/COLOR]

  
<tr><td><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit to see loan options for my scenario" class="btn" onfocus="this.blur()" />
<input type="hidden" name="submitted" value="TRUE" /></td></tr></table>
</form>
<script language="JavaScript" type="text/javascript">
<!--
var fields = document.my_form.elements;

fields["fico"].onblur = function(){
if(this.selectedIndex > 0){fields["ficonum"].disabled = "disabled";} else{fields["ficonum"].disabled = false;} }

fields["ficonum"].onblur = function(){
if(this.value != ""){fields["fico"].disabled = "disabled";} else{fields["fico"].disabled = false;} }

function reSet(){
fields["fico"].disabled = false;
fields["ficonum"].disabled = false;
}

document.my_form.onreset = reSet;
document.my_form.onsubmit = function(){ if(fields["fico"].selectedIndex > 0 && fields["ficonum"].value != ""){window.alert("You must choose only one of those two variants!"); return false;} else{return true;} } //--> </script> </body> </html>
This script processes the form. I only included the top half of the script which is a bunch of echo statements. The value for "intcredit" is not appearing in the echo statement. The rest of the script is useless if I can't see the value for this variable.

Code: Select all

<?php

include('header.html');

require_once('mysql_connect.php');

echo "Purchase Price:  $_SESSION[purchaseprice]<br>";
echo "Down Payment:  $_SESSION[downpmt]<br>";
echo "Loan Amount:  $_SESSION[loan_amount]<br>";
echo "Closing Date:  $_SESSION[date]<br>";
echo "Days in Month:  $_SESSION[days_in_month]<br>";
echo "Days Left in Month: $_SESSION[days_left_in_month]<br>";
echo "LTV: $_SESSION[ltv]<br>";
echo "CLTV: $_SESSION[cltv]<br>";
echo "Property Use:  $_SESSION[propuse]<br>";
echo "Property Type:  $_SESSION[proptype]<br>";
echo "Borrower Income:  $_SESSION[bincome]<br>";
echo "Co-Borrower Income:  $_SESSION[cincome]<br>";
echo "FICO:  $_SESSION[fico]<br>";
echo "FICO Score:  $_SESSION[ficonum]<br>";
echo "Document Income:  $_SESSION[docincome]<br>";
echo "Escrow:  $_SESSION[escrow]<br>";
[COLOR="red"]echo "Interest Credit:  $_SESSION[intcredit]<br>";[/COLOR]echo "<hr>";
As you can see the radio button code is identical to the other two and the echo statement is identical to the two above.

Can someone help me out? Thank you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That session value is never set. In fact only $_POST['downpmt'] is given to a session value.
fullfocus
Forum Commoner
Posts: 33
Joined: Fri Jun 30, 2006 2:51 pm

Post by fullfocus »

I'm a bit confused. All the other variables that appear in the echo statements have values coming across from the form. I haven't done anything differently with the intcredit variable than with the others.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Then you should double-check for typos.
fullfocus
Forum Commoner
Posts: 33
Joined: Fri Jun 30, 2006 2:51 pm

Post by fullfocus »

Hi,

After taking a long break from looking at this, I discovered upon further looking that there is a script I overlooked. This script doesn't do very much but it does post, validate and create the session variables.

I'm good now.

Thank you for your time and trying to help me out.
Post Reply