My code is designed to pull some existing data from a table of user information. In this case, the user can update his e-mail address. I have a common.php file that contains the db connect information and am using sessions. The SELECT works fine. However, the UPDATE does not update. I get no errors and no indication that the script was successful. When I check the table the value has not been update. I can use some help.
Thanks.
<?php
include("../includes/login.php");
include("../includes/functions.php");
?>
<?php
if (!isset($submitok))
{
// generate and execute query
$qryGetMemberInfo = "SELECT userid,ID,FullName,email
FROM tblUsers
WHERE userid = '$uid'";
$rsltGetMemberInfo = mysql_query($qryGetMemberInfo) or die ("Error in query: $qryGetMemberInfo. " . mysql_error());
// if a result is returned
if (mysql_num_rows($rsltGetMemberInfo) > 0)
{
// turn it into an object
$row = mysql_fetch_array($rsltGetMemberInfo);
// print form with values pre-filled
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Welcome to the-fitzgeralds.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/styles.css" rel="stylesheet" type="text/css">
</head>
<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!--DWLayoutTable-->
<tr>
<td width="426" align="left" valign="top" bgcolor="#163BA3"><img src="../images/tfn_header1.gif" width="299" height="100"></td>
<td width="34%" rowspan="2" bgcolor="#163BA3"><img src="../images/tfn_header2.gif" width="374" height="125"></td>
</tr>
<tr>
<td height="25" valign="top" bgcolor="#163BA3" align="center">
<?php
include_once ("../includes/nav.php");
?>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="5" height="25" valign="top" bgcolor="#000000"><!--DWLayoutEmptyCell--> </td>
<td class="welcome" width="780" valign="middle" bgcolor="#000000">Hello,
<?=$username?>! [<a class="welcome" href="user.php">Account Info</a>] <a class="welcome" href="javascript:window.close();">Log Out</a></td>
<td width="224" align="right" valign="middle" bgcolor="#000000" class="date">
<!-- Begin Date -->
[
<?php
$today=date(" m.d.Y");
print"$today";
?>
] </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="3%" height="89" rowspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="94%" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="3%" rowspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td valign="top">
<table cellspacing="5" cellpadding="5">
<form action="<?php echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="ID" value="<?php echo $row["ID"]; ?>">
<tr>
<td width="109" valign="top" class="txthdr">User ID:</td>
<td width="332" class="intro"><?php echo $row["userid"]; ?> </td>
</tr>
<tr>
<td valign="top" class="txthdr">Full Name:</td>
<td class="intro"><input size="50" maxlength="50" type="text" name="fullname" value="<?php echo $row["FullName"]; ?>"></td>
</tr>
<tr>
<td valign="top" class="txthdr">Current E-mail Address:</td>
<td class="intro"><input size="50" maxlength="25" type="text" name="email" value="<?php echo $row["email"]; ?>"></td>
</tr>
<tr>
<tr>
<td valign="top" class="txthdr">New E-mail Address:</td>
<td class="intro"><input size="50" maxlength="25" type="text" name="newmail"></td>
</tr>
<tr>
<td valign="top" class="txthdr">Confirm New E-mail Address:</td>
<td class="intro"><input size="50" maxlength="25" type="text" name="confirmnewemail"></td>
</tr>
<tr>
<td colspan=2><input type="Submit" name="submitok" value="Update"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="12" colspan="2" valign="top" bgcolor="#163BA3"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="100%" height="54" valign="top">
<?php
include_once ("../includes/footer.php");
?>
</td>
</tr>
</table>
</body>
</html>
<?php
}
else
{
// generate and execute query
$query = mysql_query ( "UPDATE tblUsers
SET email = '$newmail'
WHERE ID= '$ID'");
// print result
{
echo "<div class=\"blackText\">Update successful. <a href=\"../index.php\">Go back to the main menu</a>.</div>";
}
}
}
?>