/    Sign up×
Community /Pin to ProfileBookmark

Post method help

I have a problem for two php files. In a.php, I have a form and several check boxes, when I check some of them and press the “delete” button, submit.php will check the “delete_section” variable and the items corresponding to those checkboxes will be deleted. So I want to pass the variable “delete_section” from a.php to submit.php when delete button is pressed. Also, I want to use the post method to get which checkbox I have checked. My codes are:

[code=html]<form name=”Service” onsubmit=”javascript:return validate_port()”
action=”submit.php?state=<?php echo($instance)?>&section=Services<?php echo($tatal_out_service) ?>” method=”post”>

<table bgbolor=”White” width=”100%” id=”outbound_table”>

<tbody>

<tr bgcolor=”#FFFFD6″ id=”service_header”>
<th></th>
<th>Name</th>
</tr>

<?php

for ( $i=1; $i<=$tatal_out_service; $i++ ) {
if ($i%2) {
echo “<tr bgcolor=”#CCCCCC” id=”serviceList”>”;
}
else {
echo “<tr bgcolor=”#FFFFD6″ id=”serviceList”>”;
}
echo “<td align=”center” id=”service_radio”>”;
echo “<input type=”Checkbox” name=”chk[]” value=”checkpoint”>”;
echo “</td>”;

echo “<td align=”center” id=”service_name”>”;
echo “<select name=”services”>”;
$value = $config[“Services$i”][“services”];
if ($value == “”) { $value = “HTTP”; }
echo “<option value=”HTTP””;
if ($value == “HTTP”) { echo “selected”; }
echo “>HTTP</option>”;
echo “<option value=”HTTPS””;
if ($value == “HTTPS”) { echo “selected”; }
echo “>HTTPS</option>”;
echo “<option value=”pcanywhere””;
if ($value == “pcanywhere”) { echo “selected”; }
echo “>pcAnyWhere</option>”;
echo “</select>”;
echo “</td>”;

echo “</tr>”;
}
?>
</tbody>
</table>

<table width=”100%”>
<tr id=”service_button”>
<td align=”right”>
<input type=”Button” value=”Add” class=”button1″ onclick=”addService()”>
</td>

<td align=”center”>
<input type=”submit” value=”Save” class=”button1″>
</td>

<td>
<input type=”submit” value=”Delete” class=”button1″ >
</td>

</tr>
</table>
</form>[/code]

The problem is: when I use the code above for “Delete”, in submit.php I can get the _POST[“chk”]. But I don’t know how to set the vaule “delete_section” in a.php and get it in submit.php.

If I use another method:

[code=html]<?php
echo “<td align=”left”>”;
echo “<input type=”button” value=”Delete” class=”button1″ onclick=document.location.href=”submit.php?state=” . $instance . “&section=”;
echo “Services$tatal_out_service”;
echo “&delete_section=true” >”;

echo “</td>”;
?>[/code]

Then I can’t get _POST[“chk”] in submit.php.

So, can anyone please tell me how to combine these two method together, i.e., pass the “delete_section” and get _POST[“chk”]?

Thanks in advance!

Rui

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @reinmontreal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...