Jump to content


Photo

Email Form


  • Please log in to reply
5 replies to this topic

#1 piercam03

piercam03
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 July 2006 - 03:41 PM

hey, i have some code :

<center>

<form action="" method="post">
Victim Email:<br>
<input type="text" name="recipient" size="25" value="e.g. name@domain.com">
<br>
Sender Name: <br>
<input type="text" name="name" value="e.g. Charles Ray" size="25">
<br>
Sender Email: <br>
<input type="text" name="email" value="e.g. name@domain.com" size="25">
<br>
Subject: <br>
<input type="text" name="subject" size="25" value="e.g. hello!">
<br>
Text:<br>
<textarea name="message" cols="20" rows="6">Enter the message body here</textarea><br>
<input type="submit" name="submit" value="Send">


<br><br>
<?php
if ($submit) { 

if($name && $subject && $email && $message ) { 
mail("$recipient","$subject","$message","From: $name <$email>") or die("email error");
echo "Message Sent"; /
} else {
echo "All fields must be filled in!<BR>";
}
} // end php submission code
?></form>
<body>

<p>&nbsp;</p>

</body>


What it lets you do is send email form the web using a simple form.

i am currently gettin so many people usin it that i am crashing my hosts servers and i was wondering if anyone knew hot to make it once sent that a cookie is put on your system disableing you from sendin another message untill the cookie expires (5 mins)

thanks.

to visit go to www.anonymail.co.nr

also how can i make it so tht if certain words are entered then it doesnt send

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 04 July 2006 - 04:26 PM

Your code had many errors, so I fixed them. Make sure this is at the top of the page, and the html is after the closing ?>.

<?php
if ($_POST['submit']) { 

if(isset($_COOKIE['email'])){die("Error- System flood- please wait at least 5 minutes between each mail.");};

setcookie("email","1",60*5);

if(isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['email']) && isset($_POST['message']) ) { 
$headers="From: ".$name." <".$email.">";
mail($_POST['recipient'],$_POST['subject'],$_POST['message'],$headers) or die("email error");
echo "Message Sent"; /
} else {
echo "All fields must be filled in!<BR>";
}
} // end php submission code
?>
<center>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Victim Email:<br>
<input type="text" name="recipient" size="25" value="e.g. name@domain.com">
<br>
Sender Name: <br>
<input type="text" name="name" value="e.g. Charles Ray" size="25">
<br>
Sender Email: <br>
<input type="text" name="email" value="e.g. name@domain.com" size="25">
<br>
Subject: <br>
<input type="text" name="subject" size="25" value="e.g. hello!">
<br>
Text:<br>
<textarea name="message" cols="20" rows="6">Enter the message body here</textarea><br>
<input type="submit" name="submit" value="Send">


<br><br>
</form>
<body>

<p>&nbsp;</p>

</body>

Think you're smarty?

(Gone until 20 to November)

#3 piercam03

piercam03
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 July 2006 - 04:36 PM

i just get an error :


Parse error: syntax error, unexpected '/' in /home/iplaynee/public_html/main.php on line 11

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 04 July 2006 - 04:46 PM

delete the trailing slash behind "message sent"; on line eleven. of the code.

You might also consider captcha. Andy B's method is awesome, here:

http://www.digitalmi...oob/captcha.php

It will prevent automated spammers from using your service. Good stuff.

#5 piercam03

piercam03
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 July 2006 - 05:03 PM

i deleted the / anmd it sent the message but it doesnt stop me from resending another one

#6 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 04 July 2006 - 05:17 PM

Maybe your computer is blocking cookies.
If it's bots that flood your server, use captcha like michaellunsford told you.
But if it's people, you could have a table with IP addresses (everytime a form is sent your IP is added to the table). And that table deletes old records every 5 mins using a cron job.

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users