A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: php form won't send

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    16

    php form won't send

    Hi. I have problems with a php script for a form; here is the code

    Code:
    <?
    
    /*    ****************************************************************************
          *** $msg se rapporte aux variables placées dans le corps du message      ***
          ****************************************************************************
    */
    
    $msg = "E-mail from site XXX \n\n";
    
    /*    ********************************************************************************************
          ***  La chaîne Nom Expediteur est écrite dans le corps du message suivi de la variable $nom_expediteur. Idem pour les autres valeurs. ***
          ******************************************************************************************** 
    */
    
    $msg .= "From sender:    $nom_expediteur\n";
    $msg .= "E-mail:  $email_expediteur\n";
    $msg .= "Subject:    $sujet\n\n";
    $msg .= "Message:      $message\n\n";
    
    /*    *************************************************************  
          ***  \n retourne Ã* la ligne - \n\n saute une ligne ***  
          *************************************************************
    */
    
    /*    ****************************************************
          ***  N'oubliez pas de mettre votre adresse email ***
          ****************************************************
    */
    
    $to = "[email protected]";
    $subject = "$sujet";
    
    /*    *****************************************************************
          ***  Ecrit "E-mail depuis mon site" dans le champs "from"***
          *****************************************************************
    */
    
    $mailheaders = "E-mail from site XXX \n";
    
    /*    *****************************************************************
          ***  Ecrit l'e-mail de l'expéditeurdans le champs "Reply-To"  *** 
          *****************************************************************
    */
    $mailheaders .= "Reply-To: $email_expediteur\n\n";
    
    /*    ******************************************
          ***  Fonction Mail - exécute le script ***
          ******************************************
    */
    
    mail($to, $subject, $msg, $mailheaders);
    
    
    ?>
    And here there's the fla attached. It is a fault of the fla, or of the script?

    Thanks.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    this kind of script used to work with php versions older than 4.1 - see thread "php does not work" starting in 2002
    You want to add at least
    Code:
    <?
    /* ******************** 
    * get all data from request *
    ***********************/
    $nom_expediteur = $_POST["nom_expediteur"]; 
    $email_expediteur = $_POST["email_expediteur"];
    $sujet = $_POST["sujet"];
    $message = $_POST["message"];
    next you probably should add
    Code:
    /* *******************
    * this solves a problem with multi-line messages
    *******************/
    $message = ereg_replace("\r", "\n", $message);
    /************************
    * and this stops idiots from sending "cheap blue pills" mails
    * via your server 
    *********************/
    if(ereg("[\r\n]", $email_expediteur)) exit;
    You might get crippled accented characters in the mail - flash player sends them utf-8 encoded and your mail program might expect iso-latin-1 if not told otherwise (it might be clever enough to auto-detect, too)
    If this happens, you would need to either utf8_decode the message or add a content-type header to the others.

    Musicman

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    16
    Hi Musicman, thanks for what you did so far. Moreover, the provider told me that the register globals on the domain was off (is this a related issue?).
    Second: I see that you substituted POST for GET; should I substitute it in the fla too?
    Last: I didn't understood how to:

    "utf8_decode the message or add a content-type header to the others"

    (I'm very noob).

    Thanks!

  4. #4
    If you are sending the information as GET then you can replace all of his $_POST[] variables with $_GET[] variables (although I would recommend sending as POST)

    utf8_decode is a PHP function that will translate the text into a different format (ISO-8859-1).

  5. #5
    Junior Member
    Join Date
    Jan 2008
    Posts
    16
    Well... er, sirs... can you please write down a simple php script and a little fla which validates email, subject, name and message (including also those utf8 decode/multiline/antispam whom you spake of)? That's all I want.
    Tried on the net, but besides that damn script, nothing useful for my case; nothing useful here either (:-^
    It will be really appreciated! I guess it will took 10 minutes for expert people; I'm stuck with that since feb 2! :-(

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Code:
    <?
    /* ******************** 
    * get all data from request *
    ***********************/
    $nom_expediteur = $_POST["nom_expediteur"]; 
    $email_expediteur = $_POST["email_expediteur"];
    $sujet = $_POST["sujet"];
    $message = $_POST["message"];
    /* possible utf8 decode ..... */
    $nom_expediteur = utf8_decode($nom_expediteur);
    $sujet = utf8_decode($sujet);
    $message = utf8_decode($message);
    
    /* *******************
    * this solves a problem with multi-line messages
    *******************/
    $message = ereg_replace("\r", "\n", $message);
    /************************
    * and this stops idiots from sending "cheap blue pills" mails
    * via your server 
    *********************/
    if(ereg("[\r\n]", $email_expediteur)) exit;
    if(ereg("[\r\n]", $sujet)) exit;
    /*    ****************************************************************************
          *** $msg se rapporte aux variables placées dans le corps du message      ***
          ****************************************************************************
    */
    
    $msg = "E-mail from site XXX \n\n";
    
    /*    ********************************************************************************************
          ***  La chaîne Nom Expediteur est écrite dans le corps du message suivi de la variable $nom_expediteur. Idem pour les autres valeurs. ***
          ******************************************************************************************** 
    */
    
    $msg .= "From sender:    $nom_expediteur\n";
    $msg .= "E-mail:  $email_expediteur\n";
    $msg .= "Subject:    $sujet\n\n";
    $msg .= "Message:      $message\n\n";
    
    /*    *************************************************************  
          ***  \n retourne Ã* la ligne - \n\n saute une ligne ***  
          *************************************************************
    */
    
    /*    ****************************************************
          ***  N'oubliez pas de mettre votre adresse email ***
          ****************************************************
    */
    
    $to = "[email protected]";
    $subject = "$sujet";
    
    /*    *****************************************************************
          ***  Ecrit "E-mail depuis mon site" dans le champs "from"***
          *****************************************************************
    */
    
    $mailheaders = "E-mail from site XXX \n";
    
    /*    *****************************************************************
          ***  Ecrit l'e-mail de l'expéditeurdans le champs "Reply-To"  *** 
          *****************************************************************
    */
    $mailheaders .= "Reply-To: $email_expediteur\n\n";
    
    /*    ******************************************
          ***  Fonction Mail - exécute le script ***
          ******************************************
    */
    
    mail($to, $subject, $msg, $mailheaders);
    
    
    ?>
    With that script you should see whether
    - of course, you get mail at all
    - accented characters arrive properly in the message text
    - accented characters arrive properly in the subject

    Musicman

  7. #7
    Junior Member
    Join Date
    Jan 2008
    Posts
    16
    Thank you Musicman: but the fla is ok? Or could I call that script plugging in it from any form fla?

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center