Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1559 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Email Problem

Thread title: Email Problem
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
02-17-2007, 09:01 PM
#1
Xuxa is offline Xuxa
Status: Request a custom title
Join date: Feb 2006
Location: USA
Expertise:
Software:
 
Posts: 1,076
iTrader: 17 / 95%
 

Xuxa is on a distinguished road

Send a message via MSN to Xuxa

  Old  Email Problem

I have a script I made a contact form script and once I click submit it sends the email then if u refresh it, it sends it agian. How can I fix this?

02-17-2007, 09:28 PM
#2
localhost is offline localhost
localhost's Avatar
Status: Dediport Hosting
Join date: Jul 2006
Location: Berkshire
Expertise: programming, business
Software: Dreamweaver
 
Posts: 1,316
iTrader: 17 / 100%
 

localhost is on a distinguished road

  Old

Im not sure how you can fix it but it is because you are sending post data, although, why would you need to refresh?

02-17-2007, 09:34 PM
#3
Xuxa is offline Xuxa
Status: Request a custom title
Join date: Feb 2006
Location: USA
Expertise:
Software:
 
Posts: 1,076
iTrader: 17 / 95%
 

Xuxa is on a distinguished road

Send a message via MSN to Xuxa

  Old

I don't but if someone does refresh it it will send the email agian how can I stop that?

02-17-2007, 09:52 PM
#4
JochenVandeVelde is offline JochenVandeVelde
Status: Member
Join date: Sep 2006
Location: Belgium
Expertise:
Software:
 
Posts: 104
iTrader: -1 / 33%
 

JochenVandeVelde is on a distinguished road

Send a message via MSN to JochenVandeVelde

  Old

You could build an anti-flooding system, setting a cookie with time and date, after the user sent an email check whether they have waited long enough to send another email. If you need help on this, msn: info@jochenvandevelde.com

02-17-2007, 11:30 PM
#5
Zara is offline Zara
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 249
iTrader: 9 / 100%
 

Zara is on a distinguished road

  Old

The easiest way I've found is to do a redirect directly after.
header("location:sent.php");

However, if your looking for security you can use cookies as said above but people can disable them... The most secure way is to store the users IP in the database with a timestamp and see how long it's been...

02-18-2007, 07:02 AM
#6
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old

Yer I was thinking use a header redirect, thats usally what I do to stop people double posting.

The cookie idea is good as well, you could use sessions as well if you wanted to.

PHP Code:

if(isset($_SESSION['hasSent'])) {
if(
$_SESSION['hasSent'] < time() - 120) {
//Make sure it has been more then two minutes
sendEmail($_POST['data']);
//Create / Update Session
$_SESSION['hasSent'] = time();
}
} else {
//Send Email
sendEmail($_POST['data']);
//Create / Update Session
$_SESSION['hasSent'] = time();

02-18-2007, 11:08 AM
#7
Marky is offline Marky
Status: Ready for Action
Join date: Aug 2005
Location: UK
Expertise:
Software:
 
Posts: 2,775
iTrader: 14 / 100%
 

Marky is on a distinguished road

  Old

Using sessions is probably the best idea. That way you'd be able to decide on the time limit before sending it again.

02-19-2007, 02:00 AM
#8
Xuxa is offline Xuxa
Status: Request a custom title
Join date: Feb 2006
Location: USA
Expertise:
Software:
 
Posts: 1,076
iTrader: 17 / 95%
 

Xuxa is on a distinguished road

Send a message via MSN to Xuxa

  Old

Okay thanks guys

02-19-2007, 02:30 AM
#9
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Header refresh probably wouldn't work. They could just use the back button (haven't tested it though, so don't quote me).

02-22-2007, 08:17 PM
#10
TomS is offline TomS
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 5
iTrader: 0 / 0%
 

TomS is on a distinguished road

  Old

Originally Posted by Xuxa View Post
I don't but if someone does refresh it it will send the email agian how can I stop that?
Set cookies on it

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed