php - hidden variables for buttons causing problems -


here code in php. have php creditcard confirmation page, 2 button, edit details , submit. have init file perform tasks based on cc_confirm , editval is, confirm , editing details respectively.

if($_post['cc_confirm1']=='y' && $_post['$editval']!='y' && !isset($editval)) {echo '<input name="submitbtn" type="submit" value="edit details" /><input name="editval" type="hidden" value="y" /><input name="cc_confirm" type="hidden" value="n" />';
} if($_post['cc_confirm1']=='y' && $_post['$editval']!='y' && !isset($editval)){ echo '<input name="submitbtn1" type="submit" value="submit card" /><input name="card1" type="hidden" value="y" /><input name="cc_confirm" type="hidden" value="y" />';

now problem is, because using 2 hidden items, 1 @ bottom being executed. code, if press on edit details, details being submitted, credit card being runned , edit page shown after that, not serve purpose.

if interchange both button codes, submit card, showing edit page details without submitting card. have tried change name of buttons no use.how can avoid problem? appreciate effort solve.

why don't split conditions assigning value them

$continue = 0; if($_post['cc_confirm1']=='y'){ $continue++; } if($_post['$editval']!='y'){ $continue++; } else{ $continue = 0; $reason = 'editval'; } if(!isset($editval)) { $continue++; } else{ $continue = 0; $reason = 'noeditval'; } if($continue > 0){ echo '<input name="submitbtn" type="submit" value="edit details" /><input name="editval" type="hidden" value="y" /><input name="cc_confirm" type="hidden" value="n" />'; }  else{     if($reason == 'editval'){     //process     }     elseif($reason == 'noeditval'){     //process     } } 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -