Jump to content

help with form submission


searls03

Recommended Posts

submission code:

<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM cart where cart_id = ".$cid."");
while($row = mysql_fetch_array($sql)){
$id =$row["id"];
?>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$(".update<?php echo $id; ?>").validate({
		debug: false,

		submitHandler: function(form) {
			// do other stuff for a valid form
			$.post('update.php', $(".update<?php echo $id;?>").serialize(), function(data) {
				$("#price").load("index.php #price");$("#total").load("index.php #total");
			});
		}
	});
});
</script>
    <?php
}
?>

form:

 <?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM cart where cart_id = ".$cid."");
while($row = mysql_fetch_array($sql)){
$product = $row["product123"];
$price1 = $row["price"];
$id = $row["id"];
$qty = $row["quantity"];
if($product !=""){



?>

<form action="" class="update<?php echo $id; ?>" method="POST">
<input name="id" type="hidden" value="<?php echo $id; ?>" />
Quantity 
<input name="qty" type="text" value="<?php echo $qty; ?>" size="2" />$
<input name="price" type="text" value="<?php echo $price1; ?>" size="6" />
  <input type="submit" name="update" id="update" value="update" />
</form>

.

 

so my problem is that only everyother time does the page actually not refresh.......so one time it does and database doesn't update......second time it doesn't refresh and it updates(this is what I want).  why is it doing this?  is it because it is inside a div that gets refreshed?  if this is the problem....how do I fix it?

Link to comment
https://forums.phpfreaks.com/topic/256389-help-with-form-submission/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.