Recently I have been using the email riddler at DD instead of CGI mail forms because I found the latter resulted in too much spam.
Today I read my first PHP tutorial and discovered PHP mail. What I am wondering if whether it is worth using it, or whether I am better of using the email riddler. What do you think?
The basic script that I am thinking about using will be something like below. Please let me know if there is any you think I need to add or subtract to protect against SPAM. (You will notice that I haven't included my real email address below - I am completely paranoid about SPAM!)
Looking forward to reading your thoughts.Code:<html> <body><?php function spamcheck($field) { //eregi() performs a case insensitive regular expression match if(eregi("to:",$field) || eregi("cc:",$field)) { return TRUE; } else { return FALSE; } }//if "email" is filled out, send email if (isset($_REQUEST['email'])) { //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==TRUE) { echo "Invalid input"; } else { //send email $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $dates = $_REQUEST['dates'] ; $message = $_REQUEST['message'] ; mail("name@myemail.com", "$subject", "$message\nDates we would like to book: $dates\n", "From: $name <$email>" ); echo "Thank you for using our mail form $name"; } } else //if "email" is not filled out, display the form { echo "<form method='post' action='mailform2.php'> Name: <input name='name' type='text' /><br /> Email: <input name='email' type='text' /><br /> Dates: <input name='dates' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; } ?></body> </html>
Rob



Reply With Quote





Bookmarks