i set up a form a while back where people submit urls that are written to a db.
the form is fully validated.. only...I have been getting several double submissions of 
the same url.
so i want to prevent this from happening. 
javascript is out of the question. for a pop-up window.. to put an anti-double submit 
script on the form.. is not at all practical in this situation.

so i'm going with a cookie,
where i want this process to take place::

(form page) submit.php ::
1. user fills out fields and clicks submit
2. a window pops-up (this window is send-submit.php)

(process page) send-submit.php
1. a conditional statement first appears, checking to see if the cookie exists. if the 
cookie does exist than one variable in the form (it's a url submission form... so i am 
using title) is repeated, then it return's false and tells the user why. 
2. then the page checks to see if all the fields are filled correctly. 
3. if they are not, then the errors are displayed on the page for the user to see what 
the problem is. 
4. if they are, the form is mailed to the owner and written to the database and then 
redirected to a thank-you.php page.

(thank you) thank-you.php ::
this page initiates the cookie and makes it exists for a few minutes so that if 
'send-submit.php' is opened again.. it can check to see if this cookie exists. 


ok.. is this the right process? for some reason.. it's not even writing the cookie. 
here's the code i am using::

send-submit.php::

<?php 
//check to see if cookie exists
if($netdiver) {
 if($ntitle == $Title){
  echo "Sorry, but you've just submitted your site or clicked on send more than once.";
  return false;
 }
}
else {
 $ntitle = $Title;
 
 $emailto [EMAIL PROTECTED];
 
   $message .= "This information was sent on ".date('dS of F Y (H:i)')."\n";
   $message .= "Title: $Title\n";
   $message .= "<snip> other stuff...";
   
   function checktitle( $Title ) {
   if( trim( $Title ) == "" ) return false;
   return true;
   }
   
   $titleOK = checktitle( $Title );
   if( $titleOK == true) {    
    header( "Location: thank-you.php" );
    mail( $emailto, $title, $message, $headers );
    exit( );
   }
}
?>
<html.. page with all the errors displayed>

---------------------------------------
thank-you.php::

<?php
 setcookie("netdiver","$ntitle", time()+"1200");
?>
<html.. thank you page with all its content>


what am i doing wronge?
no error is displayed.. the cookie is just not setting.. 
thanks.
wes

Reply via email to