Posted by chrisv on 08/12/07 00:09
Hello everyone.
I have a simple form that is designed to update a single database
record at a time. It works fine until my pageaction variable is set
to "update". The update conditional code doesn't execute. It is
supposed to trigger an mysql record update using a predefined query.
The username used to query the database has all privileges, so that
isn't the problem. An suggestions? Here is the code:
--------------------------------------------------------------------------------------------------------------------------------------------------
<?php
//get your hbc database connection
include "db_connect.php";
/
*********************************************************************************************/
$cid =
$_REQUEST['consumer_id'];
$fullname =
$_REQUEST['consumer_fullname'];
/
*********************************************************************************************/
$date = $_REQUEST['consumer_date'];
$nursingfacility =
$_REQUEST['consumer_nursing_facility'];
$nursingfacilityaddress =
$_REQUEST['consumer_nursing_facility_address'];
$coordinator = $_REQUEST['consumer_coordinator'];
$casenote = $_REQUEST['consumer_note'];
$isn = $_REQUEST['consumer_isn'];
$status = $_REQUEST['consumer_status'];
$pageaction = $_REQUEST['pageaction'];
$change = $_REQUEST['change'];
/
***********************************************************************************************/
//handles all EDIT->UPDATE FUNCTIONS
//with $pageaction var
if($pageaction=="update"){
if($fullname!=""){
$file_update = "UPDATE `hbc_consumers`
SET
`hbc_consumers`.`consumer_fullname`='$fullname'
WHERE `hbc_consumers`.`consumer_id`='$cid'";
$result_of_updated_file = mysql_query($file_update)
or die(mysql_error());
}//use elseif to add more options
}//end UPDATE FUNCTIONS
/
*-------------------------------------------------------------------*/
/**************************** QUERY ONE
******************************/
/
*-------------------------------------------------------------------*/
/* GETS the CONSUMER RECORD */
$Select_consumer= "SELECT *
FROM `hbc_consumers`
WHERE `consumer_id`='$cid'";
/* HOLDS CONSUMER RECORD data */
$Query_consumer = mysql_query($Select_consumer) or
die(mysql_error());
$fetch_consumer_info = mysql_fetch_array($Query_consumer);
$cid =
$fetch_consumer_info['consumer_id'];
$fullname =
$fetch_consumer_info['consumer_fullname'];
$date =
$fetch_consumer_info['consumer_date'];
$nursingfacility =
$fetch_consumer_info['consumer_nursing_facility'];
$nursingfacilityaddress =
$fetch_consumer_info['consumer_nursing_facility_address'];
$coordinator =
$fetch_consumer_info['consumer_coordinator'];
$casenote =
$fetch_consumer_info['consumer_note'];
$isn =
$fetch_consumer_info['consumer_isn'];
$status =
$fetch_consumer_info['consumer_status'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Home By Choice Consumer Management - Edit Consumer File
Page</title>
<link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table align="center" border="0px" cellpadding="0px" cellspacing="0px"
width="780px">
<tbody>
<tr>
<td>
<table border="0px" cellpadding="0px" cellspacing="0px"
width="10px">
<tbody>
<tr>
<td>
<table border="0px" bordercolor="#ffffff" cellpadding="0"
cellspacing="0" width="780">
<form name="editcolor" method="get" action="" >
<tbody>
<tr>
<td class="style" colspan="4" style="padding-top:10px;">
<div id="control_panel_banner"
>
<H4>HBC Consumer Profile</
H4>
</div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="4">
<table width="100%" border="1"
cellpadding="10" cellspacing="0" >
<form name="editinfo"
action="show_profile.php" method="post">
<input type="hidden"
name="pageaction" value="update">
<input type="hidden"
name="consumer_id" value="<?=$cid?>">
<tr>
<td colspan="2"
bgcolor="#FFFF9D">
<b>Name: </b>
<?php
if($change ==
"fullname"){
echo
"<input type=\"text\" name=\"fullname\" value=\"".$fullname."\"
maxlength=\"45\" size=\"15\">
<input style=\"font-size:13px; color:black;\" type=\"submit\" name=
\"submit\" value=\"Update\">";
}else{
echo "
".
$fullname."
<a
href=\"show_profile.php?consumer_id=$cid&change=fullname\">
<img src=\"./ico_edit.gif\" border=0>
</a>
";
}
?>
</td>
-----------------------------------------------------------------------------------------------------------------------------------------
other similar options afterwards....
[Back to original message]
|