<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php require_once("includes/session.php"); ?>
<?php find_selected_item(); ?>
<?php include("includes/header.php"); ?>
<?php
if (isset($_POST['submit'])) {
$top_up_cash = mysql_prep($_POST['top_up_cash']);
$user_id = $_SESSION['user_id'];
$result = mysql_query("SELECT * FROM users WHERE id='$user_id'");
while($row = mysql_fetch_array($result))
{
$bidot_cash = $row['bidot_cash'];
}
$new_bidot_cash = $top_up_cash + $bidot_cash;
$query= "UPDATE users SET bidot_cash = '{$new_bidot_cash}' WHERE id='$user_id'";
mysql_query($query);
$message = "your top-up is complete, " . "<a href=\"userinfo.php\">" . " click here" . "</a> to check\n";
}
?>
<table id="structure">
<tr>
<div class="menu">
<ul>
<?php echo public_navigation($sel_cat, $sel_item); ?>
<br />
</ul>
</div>
</div>
<td id="item">
<?php if ($sel_item) { ?>
<h2><?php echo htmlentities($sel_item['item_name']); ?></h2>
<div class="page-content">
</div>
<?php } else { ?>
<h2>Top-up Bidot Cash</h2>
<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
key in the amount you want to top-up:<br />
<form method="post" action="topup.php">
RM :<input type="text" name="top_up_cash" /><br />
<input type="submit" name="submit" value="Confirm" />
</form>
<?php } ?>
</td>
</tr>
</table>
<?php include("includes/footer.php"); ?>
hi all,
as the code above,
i obtain a value let call it A from user then add the value A with another value from database let call it value B then store it as value C and update the C into database.
im now facing a problem which is everytime when i refresh my browser, the code run again and auto submit the value A and update into database again.
For example, C=input value+database value, then update database value =C,
when i refresh the browser, it run again the code and become C=A+ (C in database)
may i know how can i clear the content of A after a complete $_POST
is done?
let me know if my question not clear enough,thanks for help