Forum Moderators: coopster

Message Too Old, No Replies

E-Mail Send

         

DJ_Prem

6:25 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



I have a form on my site that is used to contact me on that there is a

Name
E-Mail
Message

when the user press the button the message is sent I was wondering can somehow make me a script that will check all three text boxes for data before send it along with the IP address of the sender and place cookie onto the machine that prevents the user from bombarding me with mail so lets say maximum 2 message every 60mins

Also I was wondering if I can add a new text called subject that be the subject so when I receive an e-mail it will display the e-mail address as who it is from and the subject as the subject line thank you

When they submit it will say thank you and your message received otherwise it will says sorry not sent and if they bombring me it will says you are only allowed 2 sent 2 message every 60 mins

RussellC

7:06 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



I don't think anyone here is going to do your homework for you but this can be done very easily with a few loops and the mail() function in PHP. Read up at the www.php.net manuals or search for a script that already does this.

DJ_Prem

5:16 am on Sep 6, 2003 (gmt 0)

10+ Year Member



Got it working

DJ_Prem

5:22 am on Sep 6, 2003 (gmt 0)

10+ Year Member



here it is

<?php
if (empty($_POST['name']) or empty($_POST['thereemail']) or empty($_POST['message']))
{
exit("You have not filled in all the required fields!");
}
if($_COOKIE['sentemail'] == "2"){
include("includes/sorry.template.php");
}
else{
$num = $sentmessage + 1;
$email = "Sender Name:\t".$_POST['name']."\nSender E- Mail:\t".$_POST['thereemail']."\nMessage:\t".$_POST['message']."\nIP:\t".$_SERVER['REMOTE_ADDR']."\n\n";
$to = "xx@xxx.com";
$subject = "Website Message";
$mailheaders = "From: ".$_POST['thereemail']." <".$_POST['thereemail']."> \n";
$mailheaders .= "Reply-To: ".$_POST['thereemail']."\n\n";
mail($to, $subject, $email, $mailheaders);
include("includes/thanksecho.template.php");
}
?>

How can i place a Reset button to clear all fields?

AprilS

5:23 am on Sep 6, 2003 (gmt 0)

10+ Year Member



Keep in mind that someone who is going to be "bombarding" you... will be doing so with a script or program which will not be using cookies....or even if it is a person...if they're going to do something naughty...they probably will figure the cookie thing out pretty fast. If you really are interested in logging who sent an email through your form to prevent them from doing so again within a certain time frame...I recommend logging the user IP in a flat file or even better a database like MySQL. Keep in mind though - people can spoof IP addresses really easy - if you've never seen it - an example would be watching your access logs files in real time (loads of fun).... anyway...you'll know when its happening because you'll see a visitor whos IP changes every single time they go to another page on your site. A better recommendation would be to produce an image using the GD library. (if you're not familiar...PHP can produce its own images in real time) - any way, a lot of large sites use this method these days to prevent scripts from auto-filling out their forms. You create an image that is a number or combination of letters....and require that the user type what they see in a field. This way you can see if they are really a person and took the time to fill out the form manually. I hope I didn't overload you...I just wanted to give you some options!