Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2011
    Posts
    8

    Email form through php

    I want to make an email form with ams8. I read on this forum an old post from 2004 ( on ams5 ) :
    for php this code:

    <?php

    // specify recipient email address
    $to="vio_music2009@yahoo.com";

    // send our email
    mail("$to","$from","$subject","$body");


    ?>

    form ams button on click event:

    -- clear error variable
    error = 0;

    -- Get values from input fields
    from = Input.GetText("Input1");
    subject = Input.GetText("Input2");
    body = Input.GetText("Input3");

    -- check for empty fields and deliver errors if needed
    if String.Length(from) < 1 then
    Dialog.Message("ERROR", "Bla Bla.");
    error = 1;
    end
    if String.Length(subject) < 1 then
    Dialog.Message("ERROR", "Bla Bla.");
    error = 1;
    end
    if String.Length(body) < 1 then
    Dialog.Message("ERROR", "Bla Bla.");
    error = 1;
    end

    if error~=1 then
    -- if no errors exist, send the email now and give a confirmation dialog
    HTTP.Submit("your_adress/mail.php", {from=from, subject=subject, body=body}, SUBMITWEB_POST, 20, 80, nil, nil);
    Dialog.Message("Thanks", "Bla Bla ");

    end

    The problem is : all emails received through this application are blank with [No Subject] title. Where I'm wrong? I use 000webhost.com for hosting mail.php. Please help me.

  2. #2
    Join Date
    Apr 2010
    Posts
    529
    gerbil,

    Without seeing your php file, it is hard to say. A guess is that the "subject" POST variable is not being parsed/processed correctly by your php page.

    Maybe too may "Bla, bla's" and not enough substance...

    Cheers,
    MadDogDean

  3. #3
    Join Date
    May 2011
    Posts
    8
    Ok. Php file is :

    <?php

    // specify recipient email address
    $to="myemail@yahoo.com";

    // send our email
    mail ("$to","$subject","$body","$from");

    ?>

    And ams button script on click event is:
    -- clear error variable
    error = 0;

    -- Get values from input fields
    from = Input.GetText("Input1");
    subject = Input.GetText("Input2");
    body = Input.GetText("Input3");

    -- check for empty fields and deliver errors if needed
    if String.Length(from) < 1 then
    Dialog.Message("Error", "Please enter your email address and re-submit. Thank you.");
    error = 1;
    end
    if String.Length(subject) < 1 then
    Dialog.Message("Error", "Please enter your email subject and re-submit. Thank you.");
    error = 1;
    end
    if String.Length(body) < 1 then
    Dialog.Message("Error", "Please enter your email message and re-submit. Thank you.");
    error = 1;
    end

    if error~=1 then
    -- if no errors exist, send the email now and give a confirmation dialog
    HTTP.Submit("ttp://www.mysite.webege.com/mail.php", {from=from, subject=subject, body=body}, SUBMITWEB_POST, 20, 80, nil, nil);
    Dialog.Message("Success", "Success, your info has been submitted.");
    Application.Exit();
    end

  4. #4
    Join Date
    May 2011
    Posts
    8
    Is there another php/ams8 script for email ? Pleas post it if you have one that works on ams8. Thanks.

  5. #5
    Join Date
    Apr 2010
    Posts
    529
    gerbil,

    You said that the emial worked fine, but the subject was empty... I presume the body was also empty? It seems you have nothing on your php page to parse the variable values.

    If you need more php reading, have a look at http://www.w3schools.com/php/php_mail.asp. Very basically, it shows how to disseminate the sent variables and send them to your phpmail handler.

    Cheers,
    MadDogDean

  6. #6
    Join Date
    May 2011
    Posts
    8
    All is empty: subject, from, body etc. Fortunatelly I don't know php, I look on your link but I don't know how to make it work, please help if you know how to do it.

  7. #7
    Join Date
    May 2011
    Posts
    8
    I found the solution, I post it here in case anyone would need it.

    <?php

    $subject = $_POST['subject'];
    $body= $_POST['body'];
    $from= $_POST['from'];

    // specify recipient email address
    $to="your_mail";

    // send our email
    mail ("$to","$subject","$body","$from");

    ?>

Posting Permissions

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