mardi 31 juillet 2018

Suggestion for cheking old value against new value and commenting

I am trying to compare a value in a table against a new value given in a form then giving a response of what was changed but it's giving the value if true or not

$var1 (existing value in table pulled from a search to display currently value in the form) $var2 (new value provided in form) $comment1 (the response)

this is what it looks like now:

if ($data[var1]!='$_POST[var2]')
 {
$comment1="$data[var1] changed to $_POST[$var2]";  (this will be scrubbed but I have the simple form here)
 }
else { $comment1="";}

I have tried: if($data[var1]<>'$_POST[var2]')

I have also tried adding $old_var1=$data[var1];
Then changing to if($old_var1]!='$_POST[var2]') and if($old_var1]<>'$_POST[var2]')

But the comment still shows if they are the same or not, I only want the comment to apply if they are not the same.

Aucun commentaire:

Enregistrer un commentaire