+ Reply to Thread
Results 1 to 4 of 4

Thread: Email Forms?

  1. #1
    WhiteOut is offline x10 Sophmore WhiteOut is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    111

    Email Forms?

    How can I add a form that will email me the information typed in the boxes to my site? I tried using Coffeecup Web Form Builder, but it doesnt seem to be working. I dont recieve the email. Also, Im sorry if this is the wrong section for this. I wasnt sure where to put it.

  2. #2
    Sup3rkirby is offline x10 Sophmore Sup3rkirby is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    A small town in a small city
    Posts
    181

    Re: Email Forms?

    Ehh, I would assume you are in the right place as this is about help for your site.

    Well you can easily do this with a form(of course) and a little PHP magic.

    PHP Code:
    <?PHP
     
    // SET VARIABLES / THE INFORMATION THE FORM POSTED
    $to "name@domain.com";
    $from $_POST['email'];
    $subject "EMAIL SUBJECT HERE";
    $name $_POST['name'];
    $message $_POST['message'];
    $headers .= "From: {$from}"\r\n";
    $headers .= "Reply-To: {$from}"\r\n";
    $headers .= 'X-Mailer: PHP/' phpversion();

    // CHECK WHETHER ANY OF THE FIELDS ARE EMPTY. NOTE: || means OR
    if ($from == "" || $name == "" || $message == "")
    {
      
    // CHECK IF EMAIL FOLLOWS PATTERN: NAME@DOMAIN.COM/CO.UK/ORG.NET ETC
      
    if (ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+"$from))
      {
        
    // IF ANY OF THE FIELDS ARE EMPTY SHOW THIS MESSAGE.
        
    echo "<font color=red><center>Not all required fields were filled in!";
      } else {
        echo 
    "<font color=red><center>You MUST enter a valid email address!";
      }
    } else {
     
      
    // CREATE THE BODY OF THE MESSAGE

      
    $body .= "Subject: {$subject}\n";
      
    $body .= "From: {$from}\n";
      
    $body .= "Message: \n{$message}\n";

      
    // SEND THE MAIL
      
    mail($to$subject$body$headers);

      echo 
    "<font color=red><center>Mail Sent!</center></font>";
    }

    ?>
    And then all you need is a form that has 3 fields(at least these three): name, email, message

    Those three exactly(lower case and all), since this is what the PHP will look for. That script can be customized a bit and you can do that yourself(if you know how) or you can ask for help.

    Please Note: that PHP script will simply display a message that either sends the script or reports an error. To redirect the page back to your site(like a 'success' page), add this line right after the 'Mail Sent!' line:
    PHP Code:
      echo "<meta HTTP-EQUIV='REFRESH' content='0; url=http://www.yoursite.com/'>"
    You are a 'real' programmer not when you write a program that has no errors, but when you write a program that has no errors, and that bothers you.
    "Given billions of tries, could a spilled bottle of ink ever land in the words of Shakespere?"

    -= The Last Mod of Zeeblo =-

  3. #3
    WhiteOut is offline x10 Sophmore WhiteOut is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    111

    Re: Email Forms?

    I get a message saying Warning: mail() has been disabled for security reasons. What do I do?

  4. #4
    conker87 is offline x10Hosting Member conker87 is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    65

    Re: Email Forms?

    Ask for an upgrade to intermediate PHP in your account settings.

+ Reply to Thread

Similar Threads

  1. Gmail Vs. Others
    By porky101 in forum Crossfire
    Replies: 44
    Last Post: 11-05-2011, 08:14 AM
  2. email settings - still having problem
    By Burnjob in forum Free Hosting
    Replies: 11
    Last Post: 10-21-2007, 07:56 AM
  3. AnyWhere Email V. 1.0 - RELEASED
    By Brandon in forum Scripts & 3rd Party Apps
    Replies: 24
    Last Post: 03-09-2006, 08:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers