Jump to content

page reload problem


asmith

Recommended Posts

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 ... ?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.