Having Trouble with Formmail.php

This is a discussion on "Having Trouble with Formmail.php" within the PHP Forum section. This forum, and the thread "Having Trouble with Formmail.php are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 17th, 2007, 23:29
Junior Member
Join Date: Feb 2007
Location: Buffalo
Age: 30
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Having Trouble with Formmail.php

I know very little about php, and have been struggling for the last few days to get formmail.php to work properly on my site.

Basically, all I want to do is let people enter thair name and email on my site and have it emailed to me.

I made the forms, but I don't receive the emails. Also, the page gets redirected to the wrong place when they click submit.

I've included details of the steps I've taken, a copy of the php script with my changes, and a copy of the forms on this web page: http://www.superteacherworksheets.com/help.html

Thank you for reading. I appreciate any help you can give.

- Tim
Reply With Quote

  #2 (permalink)  
Old Mar 18th, 2007, 01:02
New Member
Join Date: Nov 2006
Location: Hutchinson, MN
Age: 28
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Having Trouble with Formmail.php

Is there any more to the formmail.php file... it looks to be unfinished. its hard to see what they are doing if i dont see the mail command or headers

i will try to help you out if you need
Reply With Quote
  #3 (permalink)  
Old Mar 18th, 2007, 07:42
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 19
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to geyids Send a message via Yahoo to geyids Send a message via Skype™ to geyids
Re: Having Trouble with Formmail.php

Use this brother worked for me nicely
PHP: Select all

<?php
/*
DESCRIPTION
FormToEmail allows you to place a form on your website which your visitors can fill out and send to you. The contents of the form are sent to the email address which you specify below. The form allows your visitors to enter their name, email address and comments. If they try to send a blank form, they will be returned to the form.
Your visitors (and nasty spambots!) cannot see your email address!  The script cannot be hijacked by spammers.
When the form is sent, your visitor will get a confirmation of this on the screen, and will be given a link to continue to your homepage, or other page if you specify it.
Should you need the facility, you can add additional fields to your form, which this script will also process, without making any additional changes.
This is a PHP script. In order for it to run, you must have PHP (version 4.1.0 or later) on your webhosting account. If you are not sure about this, then please ask your webhost about it.
SETUP INSTRUCTIONS
Step 1: Put the form on your webpage
Step 2: Enter your email address and continue link below
Step 3: Upload the files to your webspace
Step 1:
To put the form on your webpage, copy the code below as it is, and paste it into your webpage:
<form action="FormToEmail.php" method="post">
<table border="0" bgcolor="#ececec" cellspacing="5">
<tr><td><font face="arial" size="2">Name</font></td><td><input type="text" size="30" name="Name"></td></tr>
<tr><td><font face="arial" size="2">Email address</font></td><td><input type="text" size="30" name="Email"></td></tr>
<tr><td valign="top"><font face="arial" size="2">Comments</font></td><td><textarea name="Comments" rows="6" cols="30"></textarea></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Send"><font face="arial" size="1">&nbsp;&nbsp;FormToEmail by <a href="<A href="http://FormToEmail.com">FormToEmail.com</a></font></td></tr">http://FormToEmail.com">FormToEmail.com</a></font></td></tr>
</table>
</form>
Step 2:
Enter the email address below to send the form to:
*/
$my_email "delete these words and put the email address only in here between the quotes";
/*
Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage:
If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"
*/
$continue "/";
/*
Step 3:
Save this file (FormToEmail.php) and upload it together with your webpage to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there.
THAT'S IT, FINISHED!
You do not need to make any changes below this line.
*/
// This line prevents values being entered in a URL
if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){print "Please enable referrer logging to use this contact form. Your message was not sent."; exit;}
// Describe function to check for new lines.
function new_line_check($a)
{
if(
preg_match('`[\r\n]`',$a)){header("location: $_SERVER[HTTP_REFERER]");exit;}
}
new_line_check($_POST['Name']);
// Check for disallowed characters in the Name and Email fields.
$disallowed_name = array(':',';','"','=','(',')','{','}','@');
foreach(
$disallowed_name as $value)
{
if(
stristr($_POST['Name'],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}
}
new_line_check($_POST['Email']);
$disallowed_email = array(':',';',"'",'"','=','(',')','{','}');
foreach(
$disallowed_email as $value)
{
if(
stristr($_POST['Email'],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}
}
$message "";
// This line prevents a blank form being sent, and builds the message.
foreach($_POST as $key => $value){if(!(empty($value))){$set=1;}$message $message "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$message $message "-- \nThank you for using FormToEmail from http://FormToEmail.com";
$message stripslashes($message);
$subject "FormToEmail Comments";
$headers "From: " $_POST['Email'] . "\n" "Return-Path: " $_POST['Email'] . "\n" "Reply-To: " $_POST['Email'] . "\n";
mail($my_email,$subject,$message,$headers);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form To Email PHP script from FormToEmail.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-uk">
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<font face="arial" size="2"><b>Thank you <?php print stripslashes($_POST['Name']); ?>!</b>
<br>Your message has been sent</font>
<p><font face="arial" size="2"><a href="<?php print "$continue"?>">Click here to continue</a></font></p>
<p><font face="arial" size="2"><b>FormToEmail</b> by <a href="<A href="http://FormToEmail.com">FormToEmail.com</a></font></p">http://FormToEmail.com">FormToEmail.com</a></font></p>
</center>
</div>
</body>
</html>
Reply With Quote
Reply

Tags
formmail

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
FormMail V3.09cl lmc148 Other Programming Languages 0 Dec 12th, 2007 22:52
Formmail.asp help MarkSensei Classic ASP 1 Jan 22nd, 2006 22:48
Problems with formMail.asp golena Classic ASP 2 Dec 14th, 2005 20:08
Need HELP - with formmail bplatosz Web Page Design 4 Nov 21st, 2005 19:01


All times are GMT. The time now is 21:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43