Menu

Changing FROM: instead of the server name

Help
2009-01-20
2013-06-03
  • indired yes

    indired yes - 2009-01-20

    First sorry for my english.

    Ok looks like is very difficult to helping about this point... I was looking reading and I dont know how to do it and some people send to the people that ask to another places to carrion. I am spending hours looking and nothing. I dont understand how.

    People like me dont know very much about programation only a few things to save the moments, so why the people with the knolew dont help just telling what to change? sorry I am frustrate now.

    PLEASE what is the change to made appear in FROM in the email the email of the sender? I know is very easy to do it but I dont know about programation and like me there more people asking the same without the easy response.

    so I have this code and I already change the        the sender email is on the field_9

    <?php

    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

    session_start();
    if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
    // File upload handling
    if($_FILES['field_2']['name']!=''){
    $field_2_filename = "file_2_".date("sihdmY").substr($_FILES['field_2']['name'],strlen($_FILES['field_2']['name'])-4);
    if(!move_uploaded_file($_FILES['field_2']['tmp_name'], "./files/".$field_2_filename)){
    die("File " .  $_FILES['field_2']['name'] . " was not uploaded.");
    }
    }

    // Checkbox handling
    $field_9_opts = $_POST['field_9'][0].",". $_POST['field_9'][1];

    mail("my@email.com","phpFormGenerator - Form submission","Form data:

    field 1: " . $_POST['field_1'] . "
    Field question 2: ".$where_form_is."files/".$field_2_filename." (original file name: " . $_FILES['field_2']['name'] . ")
    Field question 1: " . $_POST['field_3'] . "
    Field question 2: " . $_POST['field_4'] . "
    Field question 3: " . $_POST['field_5'] . "
    Field question 1: " . $_POST['field_6'] . "
    Field question 1: " . $_POST['field_7'] . "
    Field question 2: " . $_POST['email'] . "
    Field question 3: $field_9_opts
    Field question 4: " . $_POST['field_10'] . "
    Field question 5: " . $_POST['field_11'] . "
    Field question 6: " . $_POST['field_12'] . "
    Field question 7: " . $_POST['field_13'] . "
    Field question 8: " . $_POST['field_14'] . "
    Field question 9: " . $_POST['field_15'] . "

    powered by phpFormGenerator.
    ");

    include("confirm.html");
    }
    else {
    echo "Invalid Captcha String.";
    }

    ?>

    Please dont send me to a tutorial I dont know about PHP and I dont use PHP normaly for nothing. just now becouse is a GREAT scritp.

     
    • TNTEverett

      TNTEverett - 2009-01-21

      We are not here to redesign forms for every user.  If you want custom code you need to customize your own forms or pay someone to customize it for you. 
      In any case, using an example from the internet (http://www.php.net/function.mail), you can try the following.

      <?php

      $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['
      PHP_SELF']),"/"));

      session_start();
      if( ($_SESSION['security_code']==$_POST['security_code']) &&
      (!empty($_POST['security_code'])) ) {
      // File upload handling
      if($_FILES['field_2']['name']!=''){
      $field_2_filename
      = "file_2_".date("sihdmY").substr($_FILES['field_2']['name'],strlen($_FILES['fie
      ld_2']['name'])-4);
      if(!move_uploaded_file($_FILES['field_2']['tmp_name'],
      "./files/".$field_2_filename)){
      die("File " .  $_FILES['field_2']['name'] . " was not uploaded."); } }

      // Checkbox handling
      $field_9_opts = $_POST['field_9'][0].",". $_POST['field_9'][1];

      // recipient
      $to  = 'my@email.com';

      // subject
      $subject = 'phpFormGenerator - Form submission';

      // message
      $message = "Form data:
      field 1: " . $_POST['field_1'] . "
      Field question 2: ".$where_form_is."files/".$field_2_filename." (original file
      name: " . $_FILES['field_2']['name'] . ") Field question 1: " . $_POST['field_3'] . "
      Field question 2: " . $_POST['field_4'] . "
      Field question 3: " . $_POST['field_5'] . "
      Field question 1: " . $_POST['field_6'] . "
      Field question 1: " . $_POST['field_7'] . "
      Field question 2: " . $_POST['email'] . "
      Field question 3: $field_9_opts
      Field question 4: " . $_POST['field_10'] . "
      Field question 5: " . $_POST['field_11'] . "
      Field question 6: " . $_POST['field_12'] . "
      Field question 7: " . $_POST['field_13'] . "
      Field question 8: " . $_POST['field_14'] . "
      Field question 9: " . $_POST['field_15'] . "

      powered by phpFormGenerator.
      ";

      // To send HTML mail, the Content-type header must be set
      $headers  = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

      // Additional headers
      $headers .= "To: Me <".$to."> \r\n";
      $headers .= "From: ".$_POST['email']. "\r\n";

      // Mail it
      mail($to, $subject, $message, $headers);

      include("confirm.html");
      }
      else {
      echo "Invalid Captcha String.";
      }

      ?>

       
    • indired yes

      indired yes - 2009-01-21

      thank you very mucth, that resolved the problem.

      Now I have another thing and is if there a posibility to dont show in the email the link to the upload folder files in the server if the sender dont send a file. that is not nice to see in the email and also you can go and see what there in the folder.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.