Reputation: 281
I have a form on a single page, if it don't have a id I want it to insert. but if there is an id then update.
I am having difficulties getting the form values to display in the button.
I am also not sure my if or else if statement is plausible.
<?php
function myform(){
if(isset($_POST['add'])) {
if ($myform_id > 0) {
//my insert query here
$btn_value = "add";
$btn_name = "add";
}elseif(isset($_POST['edit'])){
//my update query here
$btn_value = "edit";
$btn_name = "edit";
}
}
}
?>
My form button
<input type="submit" name="<? $btn_name?>" value="<? $btn_value?>">
Upvotes: 0
Views: 37
Reputation: 335
within the php tag itself give the following statement
print "<input type='submit' name='$btn_name' value='$btn_value'>";
Upvotes: 1
Reputation: 26
try this
<input type="submit" name="<?echo $btn_name;?>" value="<? echo $btn_value;?>">
Upvotes: 1