| |

VerySource

 Forgot password?
 Register
Search
View: 1010|Reply: 6

Form problem

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-11 22:30:01
| Show all posts |Read mode
There are two pages a.php and b.php
 a.php filling form data
 b.php is used to extract the form content and add records!
 But clicking back on the menu will add an extra record. This will judge a few more.
 Excuse me: Is there any good way, or is there a way to delete the content from the post after the submission is successful!
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-7 09:00:01
| Show all posts
I usually do this

<?php
if(isset($_POST['submit'])&&$_POST['submit'] == "OK"&&$_POST['lastAction']>$_SESSION['userLastAction'])
{
$_SESSION['userLastAction']++;
...
}
?>

<form name="form1" method=post action="<?=$_SERVER['PHP_SELF'] ?>">
...

<input type=Hidden name=lastAction value=<?=$_SESSION['userLastAction']+1 ?>>
<input type=reset name=reset value="reset">&nbsp;
<input type=submit name=submit value="OK"
</form>
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-10 11:15:01
| Show all posts
Unique idea!
I solved it in this way, but I just can't return, can you return like that>?
<form action="a.php?act=regiest">
</form>
After adding
Refresh this page
location.href='b.php'
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-10 15:15:01
| Show all posts
But when act is passed with hidden, an error will occur!
Reply

Use magic Report

0

Threads

27

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-6-23 11:00:01
| Show all posts
Cookie+timestamp to prevent
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-25 16:15:01
| Show all posts
Can return
Through judgment, the content in the IF will not be executed
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-13 15:45:01
| Show all posts
The problem description is unclear!

On which page is "return"? When is "return"? After successfully inserted into the database? Which page is returned?

The data actually exists in the browser's buffer. So after refreshing the page, a piece of data will be inserted. The solution is to use header("location:".$_SERVER['PHP_SELF']);
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list