Results 1 to 2 of 2

Thread: php form problem What is the code to add this extra security to the form?

  1. #1
    Join Date
    Aug 2014
    Posts
    4
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default php form problem What is the code to add this extra security to the form?

    I have created a form using the below php. I have a couple of issues...

    1.The form seems to be working except it is not showing the sender's name/email in the 'from' section... how can I get it to show the sender's email?

    2.Is there some sort of coding I can add to help prevent spam from coming through? I saw once on a form where it asked a question and below it said 'so we know you are not a machine'. What is the code to add this extra security to the form?

    Any assistance is greatly appreciated.

    Here is the php the form is using....

    PHP Code:
    <?php

    $EmailFrom 
    "";
    $EmailTo "nina@make-upbynina.com";
    $Subject "Make-up Inquiry";
    $Name Trim(stripslashes($_POST['Name'])); 
    $Email Trim(stripslashes($_POST['Email'])); 
    $Message Trim(stripslashes($_POST['Message'])); 

    // validation
    $validationOK=true;
    if (!
    $validationOK) {
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }

    // prepare email body text
    $Body "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";

    // send email 
    $success mail($EmailTo$Subject$Body"From: <$Email>");

    // redirect to success page 
    if ($success){
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.make-upbynina.com/form-reply.php\">";
    }
    else{
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>

  2. #2
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    these links will help you figure out how to place a "from" into the mail() function your code there for the mail() function for FROM is not correct
    http://php.net/manual/en/function.mail.php
    http://www.w3schools.com/php/func_mail_mail.asp


    $headers = "From: webmaster@example.com" . "\r\n" .
    "CC: somebodyelse@example.com";

    mail($to,$subject,$txt,$headers);

    I think you need to remove the "<>" from your header section in the mail() function

    and to add a anti spam feature get recaptcha. its really easy and made by Google. Otherwise you can add a field to your form "what is 2+2" and make sure that on your submit that it is $_POST['thatField'] is set to 4

    http://www.google.com/recaptcha/intro/

  3. The Following User Says Thank You to Bionic For This Useful Post:

    kplusonline (09-03-2014)

Similar Threads

  1. Resolved form security
    By james438 in forum PHP
    Replies: 13
    Last Post: 02-24-2012, 06:04 AM
  2. Replies: 2
    Last Post: 07-21-2009, 05:45 AM
  3. Form w/ Confirm. page, Security, and Email
    By WattCode in forum Looking for such a script or service
    Replies: 5
    Last Post: 03-11-2009, 06:11 PM
  4. message form/feedback form html code
    By hyebaragi in forum Looking for such a script or service
    Replies: 1
    Last Post: 08-11-2007, 01:30 AM
  5. Form Help - Security
    By AliceD2001 in forum JavaScript
    Replies: 0
    Last Post: 11-23-2006, 12:24 AM

Bookmarks

Posting Permissions

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