+ Post New Thread
Results 1 to 5 of 5
How do you do....it? Thread, PHP in Technical; I am trying to create a php formtoemail form. I have created the form and uploaded both the form and ...
  1. #1

    Join Date
    Dec 2005
    Posts
    453
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    0

    PHP

    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:

    <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="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 = "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[Email],$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;}$messag e = $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=windows-1252">
    <meta http-equiv="Content-Language" content="en-uk">

    </head>

    <body bgcolor="#ffffff" text="#000000">

    <font face="arial">

    <object><center>
    <h1>Thank you <?php print stripslashes($_POST['Name']); ?>!</h1>
    <h2>Your form has been sent</h2>
    <h3><a href="<?php print "$continue"; ?>">Click here to continue</a></h3>
    <b>FormToEmail</b> by <a href="http://FormToEmail.com">FormToEmail.com</a>
    </center></object>

    </font>

    </body>
    </html>




    Faza

  2. #2
    Sirbendy's Avatar
    Join Date
    Nov 2005
    Posts
    2,298
    Thank Post
    8
    Thanked 203 Times in 154 Posts
    Rep Power
    111
    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.

  3. #3
    Silvor's Avatar
    Join Date
    Oct 2007
    Posts
    122
    Thank Post
    18
    Thanked 15 Times in 10 Posts
    Rep Power
    17
    Is the above code the actual code you have in FormToEmail.php?

  4. #4


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,485
    Thank Post
    867
    Thanked 854 Times in 675 Posts
    Rep Power
    197
    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.

  5. #5

    Join Date
    Dec 2005
    Posts
    453
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Yes that the formtomail.php code that i am using.

SHARE:
+ Post New Thread

Similar Threads

  1. PHP ID
    By Jackd in forum Coding
    Replies: 4
    Last Post: 30th November 2008, 02:08 PM
  2. PHP Help!
    By Cravon in forum Coding
    Replies: 2
    Last Post: 20th November 2007, 06:05 PM
  3. PHP-Fusion
    By wesleyw in forum How do you do....it?
    Replies: 0
    Last Post: 15th November 2007, 04:19 PM
  4. Help with PHP
    By Gatt in forum Web Development
    Replies: 1
    Last Post: 14th November 2006, 10:01 PM
  5. php help
    By beeswax in forum Windows
    Replies: 33
    Last Post: 14th October 2005, 05:51 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •