|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Work around 'Header already sent' problem?
On one site I am working on I set a cookie immediately upon visiting the site.
I am writing a fairly simple function that allows users to recommend the site to their friends. To help prevent spamming I wanted to set an additional cookie that would register the referral and not allow the same person to refer again for 24 hours. PHP Code:
Of course, I get the 'Headers already sent' error. Does anyone know a way around this, or if not, have a suggestion that will allow me to control the number of referrals a visitor can send? Thanks ![]() |
|
#2
|
|||
|
|||
|
Only allow up to maybe 50 referrals per IP address per day. Makes things a lot simpler.
On the referral submit form, only give the user two or three boxes to fill in so they can only submit to that may people at once. -- Wil Moore III
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
Hi laidbak,
Good idea...I use the following function. PHP Code:
thanks, Rob |
|
#4
|
|||
|
|||
|
Alright... good job. Glad I could help.
|
|
#5
|
|||
|
|||
|
If you use php's output buffering functions it should do the trick. At the begining of the code put this line:
Code:
//begin buffering ob_start(); and at the end of the code put this function Code:
//end buffering ob_end_flush(); basically what this does is prevents any text from being sent to the browser until your entire page has processed. This also will prevent the headers from being sent until after the script has run. By default PHP will automatically send headers as soon as your script attempts to send its first character to the browser. Hence the "headers already sent" error. Use the above code and your problem should be fixed. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Work around 'Header already sent' problem? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|