asmith Posted December 6, 2007 Share Posted December 6, 2007 for user registering page, or forgot password page, when user complete the form successfully , i show him/her that he/she has been do it successfully . (i use the pages that form and script are in the same file) so here comes my problem , if , if on the successful page, user click on the browser refresh button , all the script will do again . meaning if it is for forgotten password, script for example show him or e-mail him again his password . but for user registering it won't happen , cause in gave the user that his username is already taken already . how can i solve it for pages like forgotten passsword or ... ? Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/ Share on other sites More sharing options...
~n[EO]n~ Posted December 6, 2007 Share Posted December 6, 2007 What ??? Can you define again... please Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407721 Share on other sites More sharing options...
asmith Posted December 6, 2007 Author Share Posted December 6, 2007 assume a page for those who forgets their passwords. and this page e-mail them their password if they insert their account information correct . after the e-mail has been sent, the page show " an e-mail has been sent to your e-ail address." now ,if user click on his browser refresh button. the script would run again , it means it shows the user again the successful page, but will sent him again an e-mail . (i'm using form and script in the same file) Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407723 Share on other sites More sharing options...
~n[EO]n~ Posted December 6, 2007 Share Posted December 6, 2007 First you should validate your email field (do not allow blank value). Then the user will fill the email and click on Send button. After mail is sent make that field blank for e.g <?php // get email $email = $_POST['email']; // then check if field is blank or not and validate email too... if (email is blank) { show error message } else { send mail... // clear your email field $email = ""; } ?> hope you got it, and if user refreshes the page it will prompt him again to enter mail... Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407725 Share on other sites More sharing options...
rajivgonsalves Posted December 6, 2007 Share Posted December 6, 2007 One way you could do it is the following.. just a idea.. 1) When you send the password the first time store a two variable in the session say $_SESSION['passwordprevioustime'] = $_SESSION['passwordsenttime']; $_SESSION['passwordsenttime'] = time(); 2) so when he refreshes the page check for the interval in the two variables if the interval is too short do not send the mail. Although this is just an idea that popped up could have some drawbacks am thinking on it Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407726 Share on other sites More sharing options...
asmith Posted December 6, 2007 Author Share Posted December 6, 2007 mm maybe i'm doing something wrong , i 've already did that with username : at the end of the script when show successful page, i've put : unset($_POST[username]); but still email again , (i have set it to if username or e-mail was empty not to send e-mail , but seems that unset is not working) Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407729 Share on other sites More sharing options...
asmith Posted December 6, 2007 Author Share Posted December 6, 2007 yea , i can do that with putting timestamp for password . so i can limit sending the password for example less than a day . but i was searching for the simplest way Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407730 Share on other sites More sharing options...
kishan Posted December 6, 2007 Share Posted December 6, 2007 disable the refresh key on the browser.116 is for f5 Quote Link to comment https://forums.phpfreaks.com/topic/80415-page-reload-problem/#findComment-407856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.