PDA

View Full Version : Form Help (get total, send to DB)



stangn99
11-07-2007, 06:46 PM
Hello,
can anyone help me out on this?
I would like to have the number of original and copies be multiplied...and have the TOTAL TEXT BOX (or however) be updated as the user inputs the quantities.
All info in the text boxes will than be written to the DB.

This is what I have..i'm not sure where to go from here.

Thanks!




<?php
$db_host = "*****";
$db_user = "*****";
$db_pwd = "*****";
$db_name = "*****";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
<html>
<head>
<title>submit to db</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action="" method="post">
Date: <input type="text" name="date" value="<?php echo date("d-m-y"); ?>"><br />
Form Number: <input type="text" name="formNumber"><br>
Paper Type: <select name="paperColour">
<option value="Plain White"> Plain White </option>
<option value="Colour Paper"> Colour Paper </option>
</select> <br />
Originals: <input type="text" name="originals"> &nbsp;&nbsp;
Copies: <input type="text" name="copies">&nbsp;&nbsp;
Total: <input type="text" name="total" value="<?php echo $totalCopies; ?>">

<br><br>

<input type="submit" name="submit" value="Submit!">
</form>

<?php
} else {

$formNumber = $_POST['formNumber'];
$paperColour = $_POST['paperColour'];
$date = $_POST['date'];
$originals = $_POST['originals'];
$copies = $_POST['copies'];
$totalCopies = $_POST['total'];

mysql_query("INSERT INTO `clickcount` (formNumber, paperColour, date, total) VALUES ('$formNumber', '$paperColour', '$date', '$totalCopies')");
echo "Submission complete!";
}
?>
</body>
</html>