It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Won't Reset the Cookie. Weird Error.

Moderator: Malcolm

Won't Reset the Cookie. Weird Error.

Postby dflynn on Thu Apr 16, 2009 4:28 am

Hey guys,
I've never seen this one before, hopefully you can help me out here.
I get the following:

Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at ......../bathroomwriter.com/inc/connnect.php:22) in ......../bathroomwriter.com/inc/mailer.php on line 23


Here's the code for connect.php - the code allowing me to connect to my database.
Code: Select all
#I took out this bit for security purposes...
////////////// Do not  edit below/////////

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
?>


and here's the code for mailer.php - the contact form that sends to email.
Code: Select all
<?php

// load the variables form address bar
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];
$verification = $_REQUEST["verification"];

// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);
$subject = stripslashes($subject);
$from = stripslashes($from);

// check to see if verificaton code was correct
if(md5($verification).'a4xn' == $_COOKIE['tntcon']){
   // if verification code was correct send the message and show this page
   mail("webmaster@bathroomwriter.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
   // delete the cookie so it cannot sent again by refreshing this page
   setcookie('tntcon', ' ' );   <<<<<This is line 23<<<<<
} else {
   // if verification code was incorrect then return to contact page and show error
   header("Location:".$_SERVER['HTTP_REFERER']."&wrong_code=true");
   exit;
}
?>
<p>Your message has been successfully delivered. <br />
   Thank-you.</p>



Any clue as to why this is happening?
It sends the email just fine, but it doesn't reset the cookie, which allows the user to refresh the page as much as they like and resending the email while they do it.

Thanks in advance
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Won't Reset the Cookie. Weird Error.

Postby Suffer on Thu Apr 16, 2009 4:22 pm

no one idea =(
Suffer
100+ Club
 
Posts: 236
Joined: Tue Jan 20, 2009 6:34 am


Who is online

Users browsing this forum: No registered users and 0 guests