I am trying to update multiple fields with one update form. The form gets populated with all the correct information but when I go to make changes and submit the changes are not updated. Below is my form and php coding. Any help would be appreciated.
rma_update.php Form
<?php
// Connect to server and select database.
$dbhost = 'XXXXX';
$dbuser = 'XXXXX';
$dbpass = 'XXXXX';
$dbname = 'nocRMA';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
$tbl_name="rma";
// get value of id that sent from address bar
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?>
<p class="contentheading">NOC RMA Tracking Update </p>
<form action="rma_update_ac.php" method="post">
<input name="id" type="hidden" id="id" value="<?php echo $rows['id']; ?>" />
<table width="100%" border="0" cellpadding="6">
<tr>
<td width="14%"><div align="right"><strong>
<label for="location">Location:</label>
</strong></div></td>
<td width="86%"><strong>
<input name="location" type="text" id="location" value="<?php echo $rows['location']; ?>" size="50" />
</strong></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="deviceType">Device Type:</label>
</strong></div></td>
<td><input name="deviceType" type="text" id="deviceType" value="<?php echo $rows['deviceType']; ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="caTicket">CA Ticket #:</label>
</strong></div></td>
<td><input name="caTicket" type="text" id="caTicket" value="<?php echo $rows['caTicket']; ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="obsTicket">OBS Ticket #:</label>
</strong></div></td>
<td><input name="obsTicket" type="text" id="obsTicket" value="<?php echo $rows['obsTicket']; ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="netsureTicket">Netsure Ticket #:</label>
</strong></div></td>
<td><input name="netsureTicket" type="text" id="netsureTicket" value="<?php echo $rows['netsureTicket']; ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="f5Ticket">F5 Ticket #:</label>
</strong></div></td>
<td><input name="f5Ticket" type="text" id="f5Ticket" value="<?php echo $rows['f5Ticket']; ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><strong>
<label for="rmaTracking">
<div align="right">RMA Tracking #:</div>
</label>
</strong></td>
<td><input name="rmaTracking" type="text" id="rmaTracking" value="<?php echo $rows['rmaTracking']; ?>" size="50" maxlength="50" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"/></td>
</tr>
</table>
</form>
<?
// close connection
mysql_close();
?>
!
!
rma_update_ac.php file
<?php
// Connect to server and select database.
$dbhost = 'XXXXX';
$dbuser = 'XXXXX';
$dbpass = 'XXXXX';
$dbname = 'nocRMA';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
$tbl_name='rma';
// update data in mysql database
$sql="UPDATE $tbl_name SET location='$location',deviceType='$deviceType',caTicket='$caTicket',obsTicket='$obsTicket',netsureTicket='$netsureTicket',f5Ticket='$f5Ticket',rmaTracking='$rmaTracking' WHERE id='$id'";
$result=mysql_query($sql) or die (mysql_error());
// if successfully updated.
if($result){
header("Location:http://XXXXX/nocportal/rma/rma_list.php");
}
else {
//echo "ERROR";
echo "Error message = ".mysql_error();
}
?>
!
!
!
View Source For The rma_update.php. All data is being populated correctly.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RMA Tracking</title>
<link href="http://XXXXX/nocportal/templates/123wd-j15-12/css/template.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p class="contentheading">NOC RMA Tracking Update </p>
<form action="http://XXXXX/nocportal/rma/rma_update_ac.php" method="post">
<input name="id" type="hidden" id="id" value="7" />
<table width="100%" border="0" cellpadding="6">
<tr>
<td width="14%"><div align="right"><strong>
<label for="location">Location:</label>
</strong></div></td>
<td width="86%"><strong>
<input name="location" type="text" id="location" value="Dallas" size="50" />
</strong></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="deviceType">Device Type:</label>
</strong></div></td>
<td><input name="deviceType" type="text" id="deviceType" value="F5 Load Balancer" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="caTicket">CA Ticket #:</label>
</strong></div></td>
<td><input name="caTicket" type="text" id="caTicket" value="1234567" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="obsTicket">OBS Ticket #:</label>
</strong></div></td>
<td><input name="obsTicket" type="text" id="obsTicket" value="" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="netsureTicket">Netsure Ticket #:</label>
</strong></div></td>
<td><input name="netsureTicket" type="text" id="netsureTicket" value="" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>
<label for="f5Ticket">F5 Ticket #:</label>
</strong></div></td>
<td><input name="f5Ticket" type="text" id="f5Ticket" value="12312321" size="50" maxlength="50" /></td>
</tr>
<tr>
<td><strong>
<label for="rmaTracking">
<div align="right">RMA Tracking #:</div>
</label>
</strong></td>
<td><input name="rmaTracking" type="text" id="rmaTracking" value="123123123" size="50" maxlength="50" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"/></td>
</tr>
</table>
</form>
<?
// close connection
mysql_close();
?>
</body>
</html>