Hi,
I have one issue on entering data into database twice. When user add some details on my website's form pages and click on submit then data is added correctly. But if someone hit refresh button again then it will add another duplicate entry.
Is there something in php i can do to avoid duplicate form entries. thanks

Hi.

You can set mysql fileds as "unique" and check if values exists in DB before inserting.


- Mitko Kostov

You can set a session for this as well. Within the headtags place code to start and register the session:

<?php
session_start();
if (!session_is_registered("nextValidSubmission")) {
session_register("nextValidSubmission");
}
if (isset($_POST['emailAddress']) && $_POST['submissionId'] == $_SESSION['nextValidSubmission']) {
} 
$_SESSION['nextValidSubmission'] = rand(1000000,9999999);
?>

Then within your form, place a hidden field:

<input type="hidden" value="<?php echo $_SESSION['nextValidSubmission'];?>" name="submissionId"> 
:icon_eek:
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.