Jump to content

updating problem


fareedreg

Recommended Posts

I am using php with mysql database. I create a form and with the help of submit button i m updating values from textboxes to mysqltable... but the horrible problem occur when i press submit  button more than 1 time. IF i press  submit buttons 2  time.. the record which it typed enter two times in the table. I m closing mysql after update but the  problem remain same... CAN ANY  ONE  HAVE IDEA.. Here is the code

 

 

mysql_select_db($Db, $link);

 

$suppid = $q;

$bookid = $_POST["txtbook_id"];

$bookname= $_POST["txtbook_name"];

$author = $_POST["txtauthor"];

$genres = $_POST["cmdgen"];

$cost = $_POST["txtcost"];

$discprice = $_POST["txtdisc_price"];

$isbn = $_POST["txtisbn"];

$lang = $_POST["txtlang"];

 

 

$query = "INSERT INTO $Tb (supp_id,book_id,book_name,genres,author,cost,disc_price,isbn,lang) value('$suppid','$bookid','$bookname','$genres','$author','$cost','$discprice','$isbn','$lang')";

 

if(!mysql_query($query, $link))

die ("Mysql error ....<p>".mysql_error());

 

 

 

    $id=7;

    include 'call.php';

 

?>

 

<?php

    echo "<script type='text/javascript'> window.alert('Add Successfully!')</script>";

    mysql_close($link); 

?>

Link to comment
https://forums.phpfreaks.com/topic/189619-updating-problem/
Share on other sites

I would assume that you have a hidden variable in your form so the submit can be detected, and decide to do the insert. So, why not use the same value to prevent a second submission, by disabling the submit button.

 

There are alternative ways of doing this, but it depends on if you want to re-present the form, or go elsewhere after submission.

Link to comment
https://forums.phpfreaks.com/topic/189619-updating-problem/#findComment-1000794
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.