Hi all. I have been working on a action script and finally got it working. I am totally lost of how to write my PHP email codes for when the person press submit all the information they fill in is sent to me via email could someone help me please. I found tons of example off the internet to write a basic one but nothing close to what I have. Or better said none with check boxes buttons. Could someone please help me. Below is my action script code I use. The cb is for checkbox and radio buttons says radio and the other informationis normal input text box. This is working pretty good. I have problem with the check box but that I can work on later to figure out. My main concern is how can I code this action script to work in a PHP form..please help.

import fl.controls.*;
import fl.controls.RadioButtonGroup;

//This sets a group name for the radio button instances.
var myradioGroup:RadioButtonGroup = new RadioButtonGroup("RadioButtonGroup");

//This assigns the radio button instances to the radio group.
cRadio1.group = myradioGroup;
cRadio2.group = myradioGroup;

submit_btn.addEventListener(MouseEvent.CLICK, submitFunc);
var radBtns = [cRadio1,cRadio2];
var errorsNum = 0;
function submitFunc(e:MouseEvent)
{
var finalData = "";
var errorFlag = "Followings errors were found.\n";
if (name_txt.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur name.\n";
}
if (email_txt.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur email.\n";
}
if (mobile.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur phone number.\n";
}
if (!myradioGroup.selection)
{
errorsNum++;
errorFlag += errorsNum+". Select ur gender.\n";
}

if (age.selectedIndex < 0)
{
errorsNum++;
errorFlag += errorsNum+". Select any of the course.\n";
}
if (!orangecb.selected)
{
errorsNum++;
errorFlag += errorsNum+". Please check one";
}
if (!orangelcb.selected)
{
errorsNum++;
errorFlag += errorsNum+". Please check one";
}

if (message_txt.text == "")
{
errorsNum++;
errorFlag += errorsNum+". Enter ur message.\n";
}

if (errorsNum > 0)
{
mytxt.text = errorFlag;
errorFlag = "";
errorsNum = 0;
return false;
}

else
{
finalData += "Thank you "+name_txt.text+" for contacting me! I will call you at "+mobile.text+", "+"else I can mail you also at "+email_txt.text+" in "+applecb.selected+"response "+orangecb.selected+" of your message "+message_txt.text+"\n\n Your other information is, you're a "+myradioGroup.selection.value+" and is between "+age.value+"\nThanks";
mytxt.text = finalData;
}
}

Here is a simple contact form in php. This checks if the fields are empty and if the email is valid using regex pattern. If all fields are correct the php will use the mail function to send the data to the myEmail value. This may not be what you need but if you review the code, it will give you some direction on how to build a php contact form.

<?php

    // Check if submit button has been pressed.
    if(isset($_POST['submit'])){
        //Create Var's from post array.
        $fname   = $_POST['fname'];
        $lname   = $_POST['lname'];
        $email   = $_POST['email'];
        $website = $_POST['website'];
        $message = $_POST['message'];

        //Email address to send information to.
        $myEmail = 'thisismyemail@xxxxx.com';


        $error = '';

        // Check if post values are empty. If values are empty, we are appending a
        // new error message string to the $error var.
        // New $error var would be $error = ''.'error message'.'error message'....
        // and so on. This will happen for each empty value.

        if($fname == ''){
            $error .= 'Please enter Firstname';
        }

        if($lname == ''){
            $error .= 'Please enter Lastname';
        }

        if($email == ''){
            $error .= 'Please enter Email';
        }

        //Create regex pattern for checking valid emails.
        $pattern = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$";

        if(!preg_match($pattern, $email)){
            $error .= 'Invalid Email';
        }

        if($website == ''){
            $error .= 'Please enter Website';
        }

        // If now error messages have been appended to the error var we can
        // build our email
        if($error == ''){

            $headers = 'From: Contact Form '." <$myEmail>\r\n" .
            'Reply-To: '.$email . "<$email>\r\n" .
            'X-Mailer: PHP/' . phpversion();
            $to = "$myEmail";
            $subject = 'New Email From Contact Form';
            $body = 'From: '.$fname . $lname."\r\n";
            $body .= 'Email: '.$email."\r\n\n";
            $body .= $message;
            $send_email = mail($to, $subject, $body,$headers, '-f'.$,myEmail);


        }else{
            //else we will echo our error message.
            echo $error;
        }

    }




?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.