faza Posted December 3, 2008 Posted December 3, 2008 I am trying to create a php formtoemail form. I have created the form and uploaded both the form and the formtoemail.php files but when i click send i get the error below: Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Notice: Use of undefined constant Name - assumed 'Name' in \\NAS42ENT\domains\s\my site name\user\htdocs\FormToEmail.php on line 85 Below is the formtoemail.php (Sorry unable to attach it) -------------------- <?php /* Thank you for choosing FormToEmail by FormToEmail.com Version 1.4 November 27th 2005 COPYRIGHT FormToEmail.com 2003 - 2005 You are not permitted to sell this script, but you can use it, copy it or distribute it, providing that you do not delete this copyright notice, and you do not remove any reference to FormToEmail.com 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! 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 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: Name Email address Comments FormToEmail by FormToEmail.com Step 2: Enter the email address below to send the form to: */ $my_email = "my e-mail address"; /* 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 = "http://my site"; /* 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 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;} } $disallowed_email = array(':',';',"'",'"','=','(',')','{','}'); foreach($disallowed_email as $value) { if(stristr($_POST,$value)){header("location: $_SERVER[HTTP_REFERER]");exit;} } $message = ""; // This line prevents a blank form being sent while(list($key,$value) = each($_POST)){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); ?> Form To Email PHP script from FormToEmail.com Thank you <?php print stripslashes($_POST['Name']); ?>! Your form has been sent Click here to continue FormToEmail by FormToEmail.com Faza
Sirbendy Posted December 3, 2008 Posted December 3, 2008 Free PHP Mail Form — jemjabella.co.uk From the site of my missus. I use a PHP form to mail for our bullying report form.
Silvor Posted December 3, 2008 Posted December 3, 2008 Is the above code the actual code you have in FormToEmail.php?
tom_newton Posted December 3, 2008 Posted December 3, 2008 Prior warning: I am a Perl & C guy, I can't stand the sight of PHP, but I van code in it, just. Not done it in a few years mind.... Would be interested if you could isolate line 85 for us. Undefined constants in perl/php are usually due to barewords - identifiers which aren't reserved like "if" and "else" and which don't have a $ before them, so aren't variables. For example, I would suggest that: if(stristr($_POST[Name],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;} $_POST[Name] appears to be attempting to access a hash/associative array. Best way to do this is usually in the form $_POST['Name'] That *might* be your issue. Would suggest in any case yo0u use a decent "off the peg" form2email job - there's a bunch of good ones, and many bad ones. I am sure there are folks on here can make a decent recommendation.
faza Posted December 3, 2008 Author Posted December 3, 2008 Yes that the formtomail.php code that i am using.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now