Jump to content

[SOLVED] PHP script for contact form in flash


Bendeguz

Recommended Posts

Hello all

I have bought a template and i cannot get the php working. I mean i am not much for php but i think the file should be more than just what it says in the php file for the contact form. I mean this would be a simple contact form that just sends the email info to lets say johnny@yahoo.com, it does not have to send a thank you mail to the sender.

THanks and any help would be appreciated. I tryed to contact the place i purchased the template from but i have not received anything from them in 4 days. Now the code below is for the MailPHP.php

 

_root.Status=success

this is all it says in the MailPHP.php i think it should be more.

 

the variables in flash are:

txtName=_namex

txtMail=_emailx

txtPhone=_phonex

txtMessage=_commx

 

Now in the actionscript in flash i have this code:

 

function validateEmail(strEmail)
{
    return (strEmail.indexOf("@") < 2 || strEmail.lastIndexOf(".") <= strEmail.indexOf("@") + 2 || strEmail.lastIndexOf(".") > strEmail.length - 3 || strEmail.length < 8 ? (false) : (true));
} // End of the function
function clearForm()
{
    new mx.transitions.Tween(txtName, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 0, 5.000000E-001, true);
    new mx.transitions.Tween(txtMail, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 0, 5.000000E-001, true);
    new mx.transitions.Tween(txtPhone, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 0, 5.000000E-001, true);
    var _loc1 = new mx.transitions.Tween(txtMessage, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 0, 5.000000E-001, true);
    _loc1.onMotionFinished = function ()
    {
        txtMessage.text = "Message";
        txtName.text = "Name";
        txtMail.text = "Email";
        txtPhone.text = "Phone";
        new mx.transitions.Tween(txtName, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 100, 5.000000E-001, true);
        new mx.transitions.Tween(txtMail, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 100, 5.000000E-001, true);
        new mx.transitions.Tween(txtPhone, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 100, 5.000000E-001, true);
        new mx.transitions.Tween(txtMessage, "_alpha", mx.transitions.easing.Regular.easeOut, txtMail._alpha, 100, 5.000000E-001, true);
    };
} // End of the function
stop ();
mcolorx = _root.mcolorx;
new Color(_Error1).setRGB(mcolorx);
new Color(_Error2).setRGB(mcolorx);
new Color(_Error3).setRGB(mcolorx);
new Color(_Error4).setRGB(mcolorx);
btnOver = function (MC)
{
    new mx.transitions.Tween(MC._txtMC, "_alpha", normal, MC._txtMC._alpha, 50, 2.000000E-001, true);
};
btnOut = function (MC)
{
    new mx.transitions.Tween(MC._txtMC, "_alpha", normal, MC._txtMC._alpha, 100, 2.000000E-001, true);
};
_Nxt.btn.onRollOver = function ()
{
    btnOver(_Nxt);
};
_Nxt.btn.onRollOut = function ()
{
    btnOut(_Nxt);
};
stop ();
txtName.onSetFocus = function ()
{
    if (txtName.text == "Name")
    {
        txtName.text = "";
    } // end if
};
txtName.onKillFocus = function ()
{
    if (txtName.text == "" || txtName.text == " ")
    {
        txtName.text = "Name";
        new mx.transitions.Tween(txtName, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    } // end if
};
txtMail.onSetFocus = function ()
{
    if (txtMail.text == "Email")
    {
        txtMail.text = "";
    } // end if
};
txtMail.onKillFocus = function ()
{
    if (txtMail.text == "" || txtMail.text == " ")
    {
        txtMail.text = "Email";
        new mx.transitions.Tween(txtMail, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    } // end if
};
txtPhone.text = "Phone";
txtPhone.onSetFocus = function ()
{
    if (txtPhone.text == "Phone")
    {
        txtPhone.text = "";
    } // end if
};
txtPhone.onKillFocus = function ()
{
    if (txtPhone.text == "" || txtMessage.text == " ")
    {
        txtPhone.text = "Phone";
        new mx.transitions.Tween(txtPhone, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    } // end if
};
txtMessage.text = "Message";
txtMessage.onSetFocus = function ()
{
    if (txtMessage.text == "Message")
    {
        txtMessage.text = "";
    } // end if
};
txtMessage.onKillFocus = function ()
{
    if (txtMessage.text == "" || txtMessage.text == " ")
    {
        txtMessage.text = "Message";
        new mx.transitions.Tween(txtMessage, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    } // end if
};
_Nxt.btn.onRelease = function ()
{
    if (txtName.text == "Name")
    {
        new mx.transitions.Tween(txtName, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    }
    else if (!validateEmail(txtMail.text))
    {
        new mx.transitions.Tween(txtMail, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    }
    else if (txtPhone.text == "Phone")
    {
        new mx.transitions.Tween(txtPhone, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    }
    else if (txtMessage.text == "Message")
    {
        new mx.transitions.Tween(txtMessage, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 5.000000E-001, true);
    }
    else
    {
        loadVariablesNum("MailPHP.php", 0, "POST");

        clearForm(); 
        clearForm();
    } // end else if
};

Link to comment
Share on other sites

Could anyone explain how to make a php script for this email form?

I am very new to php and don't really understand it yet.

I am willing to learn and write the code if some one can explane

how this exactly corespondes with the action script in flash.

I would like to have my site up and running but my email is not

working. Is there anyway one of you guys could help me.

I have been trying to get a hold of the people that sold me the

template but sofar it's been 4 days and I have not Heard anything

from them. All i need is that the form sends me the email that's it

i guess it would be a simple email form. No return mail is required to

the sender and i would be using an existing email address not through

a server but just a regular email like geroge@yahoo.com.

 

Thanks Guys

Bendeguz

Link to comment
Share on other sites

Your flash swf is going to send the data to a file called MailPHP.php via post. Your data will show up within $_POST['txtName'], $_POST['txtMail'], $_POST['txtPhone'] and $_POST['txtMessage'].

 

You can then use the mail function to send an email.

Link to comment
Share on other sites

php mail function is

 

mail($to,$subject,$message,$from);

 

no idea how to make it work with your actionscript but you would need to use the $_REQUEST['var'] feature as normal

 

this is an example of my PHP script that works with my flash contact form

 

<?php

// read the variables form the flash post
$name = $_REQUEST["name"];
$message = $_REQUEST["message"];
$tele = $_REQUEST["tele"];
$email = $_REQUEST["email"];


mail("sales@yourDomain.co.uk", "Enquiry From website", "Name: $name\nTelephone: $tele\nEmail: $email\n$message", "From: $email");
?>

Link to comment
Share on other sites

Thanks guys for replying.

the problem is that i really have no clue how php works. I expected just to change the email address in the php and it would work but when i opened it up it only had one line that was it _root.Status=success as i said i purchased the template but i cannot get a hold of the people that sold me the template it's been 4 days and no one got back to me. This is why i came here because most people know how php works i have not got a clue.

it was supposed to be an easy set up because it's an xml flash template and i have done all the pictures and all the text but when i was going to add my email to the php i discovered that there was just that one line in there. This is why i am asking you php gurus maybe you can help me out.

Thanks

Bendeguz

Link to comment
Share on other sites

Hey Guys I have found a php contact form script i was wondering if you can help me in pointing out what i would have to change in order for it to work with the AS in flash:

here is the php code that i found I am not sure if i can use this.

I hopw someone can help.

Thanks

Bendeguz

 

<?php

// IMPORTANT NOTE: DO NOT change anything that has a $ before it
// Any line that has two slashes in front of it is a comment (and will be ignored by this script)

/*
// In case register globals is off (backwards compatibility)
// If you add additional input text fields - you need to add them here as well
// for example, if you add a text field with a variable "Phone", add:
// $phone = $HTTP_POST_VARS['Phone'];
// Remember -- you would then also need to add them in the 'Remove Slashes' section
// as $phone (for example), and somewhere in the 'msg_body' below
// I have added this example in to the script below to help give you a guide
*/

$message = $HTTP_POST_VARS['Message'];
$name = $HTTP_POST_VARS['Name'];
$email = $HTTP_POST_VARS['Email'];
$phone = $HTTP_POST_VARS['Phone'];


// Begin Censors
$message = eregi_replace('fuck', "flip", $message);
$message = eregi_replace('shit', "crap", $message);
$message = eregi_replace('bitch', "nice lady", $message);
$message = eregi_replace('ass', "butt", $message);
$message = eregi_replace('piss', "pee", $message);
// End Censors

// Remove Slashes Inserted by PHP
$name = stripslashes($name);
$email = stripslashes($email);
$phone = stripslashes($phone);
$message = stripslashes($message);



// Start Customizable Email Information
// Change the information in quotes below to fit your needs

$rec_email = "kmajszki@mountaincable.net"; // who do you want to send this email to
$subject = "Form From Web Page"; // this is the subject line of the email

// End Customizable Email Information

// The Body of the Email message
// You can customize the email you receive by changing the text inside the quotes below
// The code "\n" (without quotes) will add a new line in the email body
// Don't forget to add extra '$msg_body .='
// for each additional input field you have added to your form
// IMPORTANT NOTE: DO NOT change anything that has a $ before it

$msg_body = "Message from $SERVER_NAME\n";
$msg_body .= "*****************************************\n";
$msg_body .= "Name:  $name\n";
$msg_body .= "E-Mail:  $email\n";
$msg_body .= "Phone:  $phone\n";
$msg_body .= "*****************************************\n";
$msg_body .= "Message:  $message\n";
$msg_body .= "\n\n";
$msg_body .= "\n\n";
$msg_body .= "\n\n";
$msg_body .= "\n\n";
$msg_body .= "*****************************************\n";
$msg_body .= "\n\n";
$msg_body .= "Additional Sender Information\n";
$msg_body .= "*****************************************\n";
$msg_body .= "IP Address: $REMOTE_ADDR\n";
$HostName = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$msg_body .= "Host: $HostName\n";
$msg_body .= "User Agent: $HTTP_USER_AGENT\n";
$msg_body .= "*****************************************\n";


// Add Some Extra Header Information to the Mail
$header_info = "From: ".$name." <".$email.">";

// Now let's take the information above and mail it to the recipient
mail($rec_email, $subject, $msg_body, $header_info);



?>

Link to comment
Share on other sites

Hi,

Try this if you find it helpfull

 

AS button script

 

on(release)

{

var fname = _root.main_mc.form_mc.fname;

var sname = _root.main_mc.form_mc.sname;

var phone = _root.main_mc.form_mc.phone;

var mobile = _root.main_mc.form_mc.mobile;

var email = _root.main_mc.form_mc.email;

var errmsg = _root.main_mc.form_mc.errmsg;

errmsg.text = "";

if (fname.text == "")

{

errmsg.text = "Please Enter First Name";

}

else

if (sname.text == "")

{

errmsg.text = "Please Enter Surname";

}

else

if (phone.text == "" && mobile.text == "")

{

errmsg.text = "Please Enter Telephone or Mobile";

}

else

{

var result_lv:LoadVars = new LoadVars();

result_lv.onLoad = function(success:Boolean)

{

 

    if (success) {

        errmsg.text = "Form Submitted Successfully";

    } else {

        errmsg.text = "Please Enter valid email";

    }

}

 

var tempObj:LoadVars = new LoadVars ();

tempObj.fname = fname.text;

tempObj.sname = sname.text;

tempObj.phone = phone.text;

tempObj.mobile = mobile.text;

tempObj.email = email.text;

//tempObj.send("http://locashot/mail.php", "_blank", "POST");

tempObj.sendAndLoad("mail.php", result_lv, "POST");

                }

}

 

 

 

 

PHP mail.php script

 

First Name : '.trim($_REQUEST['fname']).'<br>

Surname : '.trim($_REQUEST['sname']).'<br>

Telephone : '.trim($_REQUEST['phone']).'<br>

Mobile : '.trim($_REQUEST['mobile']).'<br>

Email : '.trim($_REQUEST['email']).'<br>

Link to comment
Share on other sites

No one is going to write the script for you. If you really have no idea Id suggest either quickly learning php (There's a good free book in my signature, Hudzilla) or posting your request in the freelance board and maybe someone will help you out.

Link to comment
Share on other sites

Thanks Thorpe

I am not asking anyone to write the script for me, I provided the php script that i found.

All i am asking is for some one to point me in the right direction where i would have to

change the variables in the php to make it work with the flash action script.

I thought that this forum is for helping but by the looks of it no one is willing to

help. For someone that knows php it would probably take less than 5 minutes to

answer. Again i am not asking anyone to write the script just help me point out

where and what i would have to change to make the script work with the flash.

That would be it.

Thanks

Bendeguz

Link to comment
Share on other sites

Thanks Thorpe

I am not asking anyone to write the script for me, I provided the php script that i found.

All i am asking is for some one to point me in the right direction where i would have to

change the variables in the php to make it work with the flash action script.

I thought that this forum is for helping but by the looks of it no one is willing to

help. For someone that knows php it would probably take less than 5 minutes to

answer. Again i am not asking anyone to write the script just help me point out

where and what i would have to change to make the script work with the flash.

That would be it.

Thanks

Bendeguz

 

This assumes alot. Mainly that people actually know how to use flash...this is a PHP site not a flash site. I have never used flash with PHP, I actually stopped using flash after Flash 4. That was like in 2000. So for me, this problem is hard for me to solve without doing a ton of research.

 

I would look into a flash/php help forum somewhere, as that would probably have people who integrate php and flash together. There is no doubt the answer could take 5 minutes from someone who knows how to work with FLASH/PHP, for me it would take about an hour at least, which of course you could take that hour and learn the integration of PHP/FLASH and how to integrate it with your code. As all I would be doing to solve this for you is research using google, why should I do that when you are perfectly capable of that?

Link to comment
Share on other sites

Thanks Thorpe

I am not asking anyone to write the script for me, I provided the php script that i found.

All i am asking is for some one to point me in the right direction where i would have to

change the variables in the php to make it work with the flash action script.

I thought that this forum is for helping but by the looks of it no one is willing to

help. For someone that knows php it would probably take less than 5 minutes to

answer. Again i am not asking anyone to write the script just help me point out

where and what i would have to change to make the script work with the flash.

That would be it.

Thanks

Bendeguz

 

I pointed you in the right direction about 10 replies ago, what more do you want besides someone to do it for you?

Link to comment
Share on other sites

Thanks Guys

I did try to research but there is limited information that i can find.

I am not a flash guy or a php guru. All i did is purchase a template

and I did not get the full php script with the template.

I am just a business owner that is trying to fix it so i can have my

page up and running. The people i bought the template off of seem to

ignore my emails because it's been 6-7 days and i did not get ant replies

back from them. This is why i came here to php freaks because i thought

that someone would be able to help me with this problem.

The reason why i bought this template is because it was supposed to be

easy to edit. It came with all the instructions how and what to edit

in the php but when i opened the php there was only one line in it.

I have been searching on google for days and i did not find any info

that was helpful to me. All i am asking for is for some one to point

out where i have to add the variables from the flash into the php script

that i posted in one of the replies. I just don't know what and where to change

in the php to make it work. You would not even have to write me any script

just let me know where i should make the changes in the php so it would work

with the variables in the action script. That would be all.

Thanks

Bendeguz

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.