Reputation: 347
I want to get value of check box after submitting the form.Here is my code.I think the problem is in id or name.what should i do to get value and update that in database?
if(isset($_POST['submit']))
{
$check=$_POST['cbox'];
global $mysqli;
$query="Update `account_detail` set `proxy_us`=$check where `id`='".$_SESSION['account_id']."'";
$res= $mysqli->query($query) or die($mysqli->error);
}
<div class="clear"> </div>
<div class="dashboard">
<?php
global $mysqli;
$query="select `proxy_us` FROM `account_detail` where `id`='".$_SESSION['account_id']."'";
$res= $mysqli->query($query) or die($mysqli->error);
$row=$res->fetch_array(MYSQLI_ASSOC);
$us_proxy=$row['proxy_us'];
?>
<div id="proxy">
<form name="cbox" id="cbox" method="post" action="">
<input type="checkbox" name="cbox" id="cbox" value="Y" <?php if($row['proxy_us']=="Y"){?> checked <?php } ?> style="margin-left:10px;margin:4px"><b>Use Default-Proxy provided by MobilePBX for calls to US.</b>
<input type="submit" class="btn" style="margin:3px 10px 3px 10px" value="submit">
</form>
</div>
</div>
Upvotes: 2
Views: 74
Reputation: 718
You can't write.
<?php if($foo) { ?> some text <?php } ?>
Write instead of the above
<?php if($foo): ?> some text <?php endif; ?>
I hope that will solve the problem.
Upvotes: 0
Reputation: 1451
try this :
<input type="submit" name="submit" class="btn" style="margin:3px 10px 3px 10px" value="submit">
Upvotes: 3