Store the user information in an array, and then use a loop to enter the mysql database. However, occasionally the information of individual users will be entered twice. I don’t know where the logic error is. Please give me some advice:
The logic code is as follows
$data = array(); //用户信息数组 for($i=0;$i alert('$con');parent.location.href='index.php'; ";
What is strange at the moment is that the information entered by individual users is always executed twice (for example, the submitted array only has 5 elements, but the entry into the database produces 10 records)
90% of the entries are normal, only some users will do it, please give some guidance
This happens when you use location.href to jump. Some browsers may re-submit the form twice as soon as they are refreshed. There are several solutions. I will just give you an example.
I don’t see any special problems logically. I can only say that it may be that your front-end submitted two requests, and generally speaking, when inserting data, it is generally judged whether the user exists in the database, but you did not make this judgment, which also caused the information to appear. Ten records
What you should think of is:
Before inserting, judge the value of the database, at least with a unique index.
In case of individual input errors, it depends on the data in your $data.