/    Sign up×
Community /Pin to ProfileBookmark

refreshing page after posting a form…

hi guys,

when i refresh a page after submitting a form the same record gets inserted again in the database..

the answer maybe to redirect to another page..but im using the $_SERVER[‘PHP_SELF’] to process the submission..

is there any way to stop that ??

thanx alot guys..

Noor

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Daniel_TApr 09.2006 — You should always redirect after processing form-submitted data. Put the following in the appropriate place (most likely right after the data-processing PHP):[code=php]header('location: '.$_SERVER['PHP_SELF']);[/code]
Copy linkTweet thisAlerts:
@ZiplineApr 09.2006 — You could put your insert statement in and if that checks for post or a variable that is set within the if on the first submit.
Copy linkTweet thisAlerts:
@nooor83authorApr 09.2006 — thanx alot guys it works..

but why

header("Location: $_SERVER[PHP_SELF]?$_SERVER[QUERY_STRING]");

displays index.php?

is it becasuse my methos is POST ??

or am i doing something wrong..

Regards,

Noor
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYApr 09.2006 — yes, if the GET superglobal array is empty, then the query string won't contain anything.

What values do you want to pass anyway?
Copy linkTweet thisAlerts:
@nooor83authorApr 09.2006 — textfields and some hidden inputs..but now works for me..thanx

Noor
×

Success!

Help @nooor83 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...