Hi,

When i hit the F5 key on the keyboard after Insert into process, it adds same record into database again. How can solve this problem?
Thanks

restrict your query with the name of your entries and show name is already existed in database like:

$qry1="SELECT * FROM `yourtable`  WHERE name='".$_POST['name']."'";
		$res1=mysql_query($qry1) or die(mysql_error());
		$num1=mysql_num_rows($res1);
if($num1>0)
{
echo "the name is already in use";
}
if($num1==0)
{
write your insert query...
}

I have several users to use my program. Is there any way to flush things after inserting or submitting?

i have inserted 1 user n its related content using check box in database i want to ristrict the same user to enter same content again what i have to do for it?

i have inserted 1 user n its related content using check box in database i want to ristrict the same user to enter same content again what i have to do for it?

have you inserted user id in content table???
be more clear about this...i can help you..

I think there is alternative solution, instead of writing data in the database that may be useful only for verification purposes.

you can make a verification in this way

if (isset($last_rec_id))
  {
  $test_query = mysql_query(select 'some data to verify here' from 'yourtable here');
  $test_data = mysql_fetch_row($test_query);
if ('your_value_to_be_inserted' === '$test_data[0]')
  {
  die 'You are trying to enter these values twice'
  } 
  }
else
  {
   //run your insert query here and add at the end the following
  $last_rec_id = mysql_insert_id($insert_connection);
  }

In this way you will make sure that last data entered from your particular session does not duplicate

I 'll describe the project to u in detail..

1) Allow registered users to:
1. make bookings for sports facilities like swiming, spa etc.

I took three tables
1. USERS:
-username (primary key)
-userid
-password
2. Sports_name: To add facility by admin side
-sportid (primary key with auto increment)
-sport name
3. Sports_facility:Selecting sport facility from user side
-sportid
-username (The username from table USERS which is registered.)

Q. Now how i am gona make relation while adding, modifying, displaying n deleting the facilities which registered user has booked for himself..?

Please tell me how to equi-join those querries..?

As above Now i want to restrict a user who has added a facility in its account n made bookings for it...
On what condition it is possible?

<?php
session_start();
$isSave="";
session_register("$isSave");

if (isset($_POST)&& $_POST=="")
{
$sql_query = "INSERT INTO ...)";
$sql_query.="VALUES(....)";
mysql_query($sql_query, $dbLink);
$isSave="Yes";
session_register("$isSave");
header("location:trangnhap.php");
}
?>
<form name="nhap" action="#" method="post" onSubmit="return checkInput();" id="submit">

<input type="submit" name="submit" value="Cập nhật" class="Nut"/>

Comments
Useful post

Send the data to a formhandler file. F5 (reload/refresh) send the same data via the form again. form -> formhandler (process data) -> redirect back to form or other page.

You can put the $_POST data into a $_SESSION array to send it back to the form to repopulate it with the same data if there is an error. Inelegant but it works.

This article has been dead for over six months. Start a new discussion instead.