I am in the process of making it possible to edit data which comes out of a database, and then gets update upon submission. Simple enough, I've done it before, but this time it is not working, and for the life of me I can't understand why not.
PS. Very Sorry about the messiness of the code, I'll clean it up once I've got this worked out, if you cant understand it, I'll clean it up before you can see whats wrong.
Code: Select all
if (isset($_POST['editclientdetails'])) {
$hello = $_POST['clientnama'];
$idd = $POST['idd'];
$postaddlineone = $POST['postaddlineone'];
$postaddlinetwo = $POST['postaddlinetwo'];
$physaddlineone = $POST['physaddlineone'];
$physaddlinetwo = $POST['physaddlinetwo'];
$phone = $POST['phone'];
$fax = $POST['fax'];
$contactone = $POST['contactone'];
$mobileone = $POST['mobileone'];
$emailone = $POST['emailone'];
$contacttwo = $POST['contacttwo'];
$mobiletwo = $POST['mobiletwo'];
$emailtwo = $POST['emailtwo'];
$poststate = $POST['poststate'];
$postpostcode = $POST['postpostcode'];
$postsuburb = $POST['postsuburb'];
$physstate = $POST['physstate'];
$physpostcode = $POST['physpostcode'];
$physsuburb = $POST['physsuburb'];
$deposita = $_POST['deposit'];
$activea = $_POST['active'];
/* if($deposita == "yes")
{
$deposit = "1";
}
else
{
$deposit = "0";
}
if($activea == "yes")
{
$active = "1";
}
else{
$active = "0";
} */
echo $idd;
echo $hello;
$sql = mysql_query("UPDATE clients SET clientname='$hello', postaddlineone='$postaddlineone' WHERE id = '$idd'", $con);
if ($sql) { // mysql saved ok
$save_result = "<b>Task Marked: Completed Task on: </b>";
}
ELSE
{ // mysql failed to save
$save_result = "<font color=red><b>Failed Completion</b></font>";
}
$theclient = $hello;
}
else
{
$theclient = $_GET['clientname'];
}
$showtask = MYSQL_QUERY("SELECT * FROM clients WHERE clientname = '$theclient'");
while ($row = mysql_fetch_assoc($showtask)) {
$id = $row['id'];
$clientname = $row['clientname'];
$postaddlineone = $row['postaddlineone'];
$postaddlinetwo = $row['postaddlinetwo'];
$physaddlineone = $row['physaddlineone'];
$physaddlinetwo = $row['physaddlinetwo'];
$phone = $row['phone'];
$fax = $row['fax'];
$contactone = $row['contactone'];
$mobileone = $row['mobileone'];
$emailone = $row['emailone'];
$contacttwo = $row['contacttwo'];
$mobiletwo = $row['mobiletwo'];
$emailtwo = $row['emailtwo'];
$poststate = $row['poststate'];
$postpostcode = $row['postpostcode'];
$postsuburb = $row['postsuburb'];
$physstate = $row['physstate'];
$physpostcode = $row['physpostcode'];
$physsuburb = $row['physsuburb'];
}Code: Select all
<form method="post">
<input type="text" value="<? echo clientname; ?>" name="clientnama">
<input type="hidden" name="idd" value="<? echo $id; ?>">
<input type="submit" value="submit" name="editclientdetails">