First, let me say I love this forum, it appears to have some very helpfull staff and members...
I have a database that I have created a table that I want to insert a hidden field amount when the users presses a form button...
<html>
<head>
<basefont face="Arial">
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
// form not submitted
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="hidden" name="amount">
<input type="submit" name="submit">
</form>
<?php
}
else {
// form submitted
// set server access variables
$host = "DBHOST";
$user = "DBUSERNAME";
$pass = "XXXXX";
$db = "DBNAME";
// get form input
$id=1;
$amount=1000;
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "INSERT INTO credits (id, amount) VALUES ($id, $amount)";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// print message with ID of inserted record
echo "New record inserted with ID ".mysql_insert_id();
// close connection
mysql_close($connection);
}
?>
</body>
</html>
I can't seem to figure out how to get it to ADD to the field amount? I want the amount to be added to the value that is already in the DB say for instance...
$id 1 amount =500
when the user presses the button, I want it to ADD 1000 so that the database will then have : $ID 1 amount=1500