# Embeding a server-side script in flash

**URL:** https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434
**Category:** flash
**Created:** [December 11, 2002, 7:51pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434 "2002-12-11T19:51:33Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![thediablo](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@thediablo](https://forum.kirupa.com/u/thediablo)
#### Post date: [December 11, 2002, 7:51pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/1 "2002-12-11T19:51:33Z")

</div>

Hi!  
i found ure email form php code.

```php
<?
$recipient = "fake@fake.com";
unset($HTTP_POST_VARS['onLoad']);
unset($HTTP_POST_VARS['clear']);
$body = "The following information was submitted...

";
foreach($HTTP_POST_VARS as $key => $value) {
    $key = substr($key, 0, -4);
    $body .= "$key: $value
";
}
$from = $HTTP_POST_VARS['name_txt'] . " <" . $HTTP_POST_VARS['email_txt'] . ">";
mail($recipient, $HTTP_POST_VARS['subject_txt'], $body, "From: $from");
?>

```

but i dont know how to use it on FLASH, can u explain me a little, i need some dynamic text fields?

thanks in advance.

Note: if anyone else knows, help me 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 11, 2002, 8:57pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/2 "2002-12-11T20:57:54Z")

</div>

anyone? :-\

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 11, 2002, 9:11pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/3 "2002-12-11T21:11:13Z")

</div>

I’m not sure but I think you need some dynamic text fields!  
With variable names “name\_txt”, “email\_txt” and “subject\_txt”.  
And to use it with flash simply add a this code on the first frameof yur movie.  
loadVariables(“myphpfile.php”, POST);  
change myphpfile.php to the name of the php file you have!  
Should werk! :-\

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 11, 2002, 9:18pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/4 "2002-12-11T21:18:08Z")

</div>

welllllll here’s another php code for sending mail… I understand this one better…

```php
<?
$ToEmail = "*youremailaddresshere*";

##$ToName = "*your name/nickname*";
$ToSubject = "*Your subject here*";

$EmailBody = "Sent By: $name
Email: $email
WebSite: $website

Message:
$comments
";

$EmailFooter="
This message was sent by: $name from http://yousite or sumthin";

$Message = $EmailBody.$EmailFooter;

mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">");

Print "yourdynamictextbox=Complete - Your mail has been sent";

?>

```

You should change the things in _Italic_. (Your email, name etc)  
And “email”, “website”, “comments” next to “EmailBody” are the variable names of the textboxes! you could add, delete, change them any way you want  
and the last one “yourdynamictextbox”. That should be the textbox where it displays the text “Complete - your…” Just for the visitor to see that the mail has been sent. But If you don’t wan ti you could just delete that line!  
🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 3:57pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/5 "2002-12-12T15:57:03Z")

</div>

thanks syko but how do i implement the code in flash…

i add dynamic boxes and give them the VAR names of the php code?

Thanks!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 3:59pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/6 "2002-12-12T15:59:03Z")

</div>

Also, is that all the code u need?  
u dont need to specify the SMTP or something?  
Does flash have a built in mailer?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 5:26pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/7 "2002-12-12T17:26:10Z")

</div>

:\*(

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 5:35pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/8 "2002-12-12T17:35:55Z")

</div>

well… that’s all you need!  
just make textboxes with variable names  
“name”, “email”, “website”, “comments”  
.  
You can change the layout of the email message.  
Change the line that starts with “EmailBody=”

```php

 <----- this is a line break

```

This layout would appear like this:  
[isf the name was “Syko”, website was “www.sss.ss” and comments were “mycomments here” and email was “[myemail@email.com](mailto:myemail@email.com)”

> Sent by:Syko  
> Email: [myemail@email.com](mailto:myemail@email.com)  
> WebSite: www.sss.ss

Message:  
mycomments here

This message was sent by Syko from www.sss.ss

the last piece “thi message was sent by…” Is the next line that starts with"EmailFooter"  
“$” in php means that the word followed by it is a variable! like a varibale name of a text box for example

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 6:19pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/9 "2002-12-12T18:19:36Z")

</div>

You the man!!!

thats all i need to know.

Thanks!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 7:40pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/10 "2002-12-12T19:40:19Z")

</div>

:o someone change the title 😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 8:00pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/11 "2002-12-12T20:00:40Z")

</div>

ok i made everything, i got the form in FLASH,

but the button is not working can you help me?

```php

on (release) {
 if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
 gracias = "Email Incorrecto";
 }
 else if (!FirstName.length) {
 gracias = "Escribe un Nombre";
 }
 else if (!ToComments.length) {
 gracias = "Escribe un Mensaje";
 }
 else {
 loadVariablesNum ("/scripts/solicitud.php", "0", "Post");
 gracias = "Enviando su solicitud...";
 }
}

```

thats the code. i put it in the button, but nothing happens

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 12, 2002, 8:17pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/12 "2002-12-12T20:17:27Z")

</div>

maybe that code is not compatible with MX?

i have the form at my site [www.zonahost.net](http://www.zonahost.net)  
is at the bottom. of the page.

when u click the btn nothing happens.

:\*(

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 3:36pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/13 "2002-12-13T15:36:34Z")

</div>

can anyone help me here. Thanks.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 4:48pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/14 "2002-12-13T16:48:30Z")

</div>

humh… it should werk! Make sure you upload it before testing and check if your server supports php!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 4:54pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/15 "2002-12-13T16:54:37Z")

</div>

yep and yep…

i upload it and the server supports php.

What else could be the prob?

and its uploaded, check in [zonahost.net](http://zonahost.net)  
Enter and at the botton is the form.

:o and also, the button at flash dosent work, the AS that are supposed to work in flash dosent work.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 5:19pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/16 "2002-12-13T17:19:52Z")

</div>

I´ve seen your PM, but server-side thangs is not my strong side.  
[SIZE=1]not even my weak side, even the weak I know sumthing about.:P[/SIZE]

=)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 5:21pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/17 "2002-12-13T17:21:06Z")

</div>

:o

Ok thanks!

:D:D

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 6:31pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/18 "2002-12-13T18:31:41Z")

</div>

now everything is working fine but the script stays at

Sending email…

Do you think this is something in the server?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 6:39pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/19 "2002-12-13T18:39:25Z")

</div>

Well, thats what you wrote in your script, try loading the output into flash, then define an onLoad to check if that output is success, after that report to the user that the email had been sent succesfully. You should use LoadVars object, not loadVariables. If ur using flash 5, check the XML Object.

h88 8]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 13, 2002, 6:59pm UTC](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434/20 "2002-12-13T18:59:14Z")

</div>

hmh… haven’t purchased my own domain with php yet. Can’t test it! gonna buy one soon and put my homepage up!!

[Next page](https://forum.kirupa.com/t/embeding-a-server-side-script-in-flash/9434.md?page=2)
