开发者

Keep getting undefined index error, cant figure out how to declare value in the submodal window

I am a beginner in PHP and MYSQL, I really need your help. I am attempting to insert new information into the database, and installed the submodal feature to input and view customer notes. I am attempting to Insert a "New Customer" into the database, and keep getting undefined index error for the "Notes" field...I am not sure how to declare the value since I am using the submodal feature and also have an Image that the user will click on to activate the submodal. Here is the code for the table...thank you all very much!!

 <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" target="_top" id="form1">
<table width="30%%" border="1">
<tr>
  <td>First Name:</td>
  <td><label for="First_Name"></label>
  <input type="text" name="First_Name" id="First_Name" /></td>
</tr>
<tr>
  <td>Last Name:</td>
  <td><label for="Last_Name"></label>
  <input type="text" name="Last_Name" id="Last_Name" /></td>
</tr>
<tr>
  <td>Address:</td>
  <td><label for="Address"></label>
  <input type="text" name="Address" id="Address" /></td>
</tr>
<tr>
  <td>City:</td>
  <td><label for="City"></label>
  <input type="text" name="City" id="City" /></td>
</tr>

<tr>
  <td>Zip:</td>
  <td><label for="Zip"></label>
  <input type="text" name="Zip" id="Zip" /></td>
</tr>
<tr>
  <td>Phone:</td>
  <td><label for="Phone"></label>
  <input type="text" name="Phone" id="Phone" /></td>
</tr>
<tr>
  <td>E-Mail:</td>
  <td><label for="Email"></label>
  <input type="text" name="Email" id="Email" /></td>
</tr>
<tr>
  <td>Fee:</td>
  <td><label for="Fee"></label>
  <input type="text" name="Fee" id="Fee" /></td>
</tr>
<tr>
  <td>Referral Source:</td>
  <td><label for="Referral_Source"></label>
  <input type="text" name="Referral_Source" id="Referral_Source" /></td>
</tr>
<tr>
  <td>Notes:</td>
  <td><a href="subform.php?Id=<?php echo $row_Recordset1['Id']; ?>" class="submodal"><img     
  src="Images/editnote.png" class="pencil" width="33" height="33" /></a></td>
开发者_C百科</tr>
<tr>
  <td>&nbsp;</td>
  <td><input type="submit" name="Submit" id="Submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />

 Notice: Undefined index: Notes in /home/content/02/8116402/html/testleadform.php on line 55

                        GetSQLValueString($_POST['Notes'], "text"));


 Notice: Undefined index: Notes in /home/content/02/8116402/html/testleadform.php on line 55

Warning: Cannot modify header information - headers already sent by (output started at    
/home/content/02/8116402/html/testleadform.php:55) in /home/content/02/8116402/html/testleadform.php       
on  line 65

Line 65: header(sprintf("Location: %s", $insertGoTo));




<?php
 ini_set('display_errors', 'On');
 error_reporting(E_ALL);
?>
<?php require_once('Connections/cms.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) :    
 mysql_escape_string($theValue);

switch ($theType) {
case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
 case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
 }
 return $theValue;
}

}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO Leads (First_Name, Last_Name, Address, City, `State`, Zip, Phone,   
Email, Fee, Referral_Source, Notes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                   GetSQLValueString($_POST['First_Name'], "text"),
                   GetSQLValueString($_POST['Last_Name'], "text"),
                   GetSQLValueString($_POST['Address'], "text"),
                   GetSQLValueString($_POST['City'], "text"),
                   GetSQLValueString($_POST['State'], "text"),
                   GetSQLValueString($_POST['Zip'], "text"),
                   GetSQLValueString($_POST['Phone'], "text"),
                   GetSQLValueString($_POST['Email'], "text"),
                   GetSQLValueString($_POST['Fee'], "int"),
                   GetSQLValueString($_POST['Referral_Source'], "text"),
                   GetSQLValueString($_POST['Notes'], "text"));

mysql_select_db($database_cms, $cms);
$Result1 = mysql_query($insertSQL, $cms) or die(mysql_error());

$insertGoTo = "leads.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
 header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_cms, $cms);
$query_Recordset1 = "SELECT * FROM Leads";
$Recordset1 = mysql_query($query_Recordset1, $cms) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>


If it is valid for $row_Recordset1['Id'] to be unset, try doing the following:

<a href="subform.php?Id=<?php if (isset($row_Recordset1['Id'])) { echo $row_Recordset1['Id']; } ?>" class="submodal">


Did you access this page through a form? If not, $_POST does not exist. Also if there is not a field known as Notes (case sensitive - i.e. <input name="Notes">), then this field is non-existent and will throw this type of error. If it is returning to this page, check that $_POST exists with if(isset($_POST)) before trying to access the variable.

ORIGINAL ANSWER

If you are getting an undefined index error in your Notes: section, then $row_Recordset1['Id']; does not exist. Make sure that your database field is Id (case sensitive) and not ID, id, or some variation. class="submodal" looks like HTML code and should not effect this issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜